---
# System prepended metadata

title: vim
tags: [cmd]

---

vim
===
所有資料整理自下述YT [Lecture 3: Editors (vim) (2020)
](https://www.youtube.com/watch?v=a6Q8Na575qc)
- ### mode

- normal mode
navigating the file and reading things
- insert mode
         press i can become insert mode
         insert mode press esc can come back normal mode
- replace mode 
     press R and you can go to replace mode
- visual mode 
      press v and you can go to visual mode
- line mode
      use shift+V to Enter this mode
- block mode
      Ctrl + V can enter this mode
- ### command-line
      use : can enter this mode
        - : w 
        wirtten the file and change the file data
        - : quit (can be also use as :q)
        quit the window I use now
            - if i want to quit all the windows
              I can use ":qa" which mean quit all 
        - : help 
        :help 後面加任何指令可以查詢他的用途
        像是 :help :q 可以查詢如何用 :q 
        :help :w 可以查詢怎樣用 :w 
        查詢完要退出就一樣使用 :q 來處理。
        - :sp 
        it can open a new window for the same buffer
            - p.s. :help w 跟 :help :w 不同
            前者是查W在normal mode 下面的用途 
            後者是查:w這個command的用途
        - ctrl - V can also write ^V or <C-V>
        - ^ = caret, < = angle bracket。
- ### navigate inside vim
    h=left;
    j=down by one line;
    k=up one line;
    l=right;
        - but if i want move 4 at a time i can use
          4+h=equal to I press four time h.
          4+j=equal to I press four time j.
    - other move key                        
    w=move to next word;
    b=back to last word;
    E=move to end of the word;
    0=move the begging of line
    $=move to the end of line
    ^=move to the first non-empty character of line
    ctrl+u=scroll up the whole page
    ctrl+d=scroll down the whole page
    Capital G(shift and g)= move all the ways down
    gg =moves all the way up;
        
    - whole screen control
    
    l=move the lowest line of your screen;
    m=move to the middle line of your screen;
    h=move the the highest line of your screen;
    
    - find and jump
    F+a=find the first "a" before the line;
    f+a=find the first "a" in the following line;
    to=jump to the next o, and be one character before;
    Ti=jump to the backward i, but one character after 
    - use % can jump between () or[] 
    - use / + anything you want to search
                            
- Delete
    - press "d" to delete the content
      dw= will delete the word.
      de= will delete end of the word.
      dd=it will delete the whole line
        - I can also combine d to other command
          7dw=delete 7 words.
    
    - press 'c' to become change the mode
      ce= change end of the word,and enter insert mode.
      cc= delete all of the line, and enter insert mode. 
    - press 'x' to delete single character
    - press 'r' to replace the character
      r+a=replace the current character to become a.
                            
    - undo and redo
      click "u" can cover the movement u do.
      click "ctrl+R" can redo the commnet again.                      
                            
    
- about insert mode
    - press "o"
    create a newline and enter insert mode.
    -press "O"(Capital O)
    create a newline above and enter insert mode.
- about copy and paste
    - press "y" for copy (Y stand for yank)
      yw=it will copy the word and you can pree 'p'to paste it
      yy=copy the whole line and you can use 'p' to paste it
    - press "p" for paste
    
                            
    most of the time we use copy and paste with visual mode.
    - press 'v' and you can use as the same in normal mode and press'y' to copy 'p' to paste it.
    - press 'V'(capital V) and you can enter visual line mode, and can press 'y' to copy the whole line and press 'p' to paster the whole line you just copy.
    - press 'C-V'(ctrl+v) and you can enter block mode to choose where you want to use select it as a rectangular.
    - press 'v' and select the space you want and use 'shift + ~ ' and you can change the big letter to small and the small one to big letter.
                            
                            
- change content
    - d2wi
    delete two words and enter insert mode
    - c2w
    change 2 words
    - ci[
    use this i can change the words 'inside' the 'bracket'([)
    - di(
    delete the content inside (
    - da(
    It will delete 'all' inside parentheses() and include the parenthese
                            
- repeat the same things
  if you want repeat the same motion you just done.
  you can press '.'
  'jj.'meant you go down two lines and repeat what you do again.

- cw = dwi
                            
- vim ~/.vimrc
上述指令可以使你自由的改變你的vim的版面，可以增加行數或是任何改變顯示，github上面會有很多人分享自己的vim版面，可以上去查看。