sudo apt-get install vim
- To execute commands of vim - Esc
- Insert/type data - i
- arrow keys - up(k), down(j), left(h), right(l)
- exit on vim - :q
- exit with save - :wq
- exit without saving - :q!
- save file - :w
- delete line - dd
- down of the file - G
- go back to top file - gg
- undo the delete line - u
- specify number jump - 10 down(j)
- back the changes - ctrl + r
- contious delete - dd then press .
- copy paste - copy(yy) paste(p) for paste below, paste(P) for paste above
- Visual mode or Hightlight - V
- Insert empty line - below(o) above(O)
- move across to the word - w
- move back across to prev word - b
- show the number of line - :number-of-line (:10 + enter)
- cursor to display on the line - 0
- cursor of the beginning of the line - ^
- cursor of the last of the line - $
- change specific then inser mode - c t j(want to remove)
- delete specific character - d t /(character)
- search with specific word - *(must cursor on the word inorder to search)
- focus on specific character - t
- next to instance - ;
- move view on the middle - zz
- insert before the text - a
- insert mode on the last line code - A
- delete based on the cursor - x
- inser mode on beginning line - I
- to lowercase - ~
- read last thing you do or command - .
- replace depend the cursor - r
- check the end based on the character - %
- Ctrl W + L - Move the current window to the "far right"
- Ctrl W + H - Move the current window to the "far left"
- Ctrl W + J - Move the current window to the "very bottom"
- Ctrl W + K - Move the current window to the "very top"
Check out :help window-moving for more information
- :res 50(width) - Resize vertical base on
- :vertical res 50 - Resize horizontal
- :Git (or just :G), which calls any arbitrary Git command.
- :G add
- :G commit
For example, to search for the first occurrence of the string ‘foo’ in the current line and replace it with ‘bar’, you would use:
:s/foo/bar/
To replace all occurrences of the search pattern in the current line, add the g flag:
:s/foo/bar/g
If you want to search and replace the pattern in the entire file, use the percentage character % as a range.
This character indicates a range from the first to the last line of the file:
:%s/foo/bar/g
Main used commands
- w
- b
- t /(specific character)
- zz
- a and A
- I
- ~ (turn the opposite letterseCase)
- .
- % d %
- V y pp - copy & paste based on highlight
- v t c
For Reference: https://www.youtube.com/watch?v=IiwGbcd8S7I