Record several commands in vimtutor
- h, j, k, l - move cursor, h is left, j is down, k is up, l is right.
- esc - back to Normal mode.
- :q! - exit the editor, without changes(discarding changes).
- x - delete character under the cursor.
- i - insert text before the cursor.
- A - append text at the end of line.
- vim filename - start vim from the shell prompt type.
- :wq - save a file and exit.
- dw - delete a word
- d$ - delete to the end of the line.
- w - move to the start of next word.
- e - move to the end of the current word.
- $ - move to the end of the line.
- many commands that change text are made from an operator and a motion, eg: dw.
- typing a number before a motion repeats it that many times(operator [number] option), eg: 2w, 3e.
- 0 - move to the start of the line.
- dd - delete a whole line.
- u - undo the last command
- U - undo all changes on a line.
- ctrl+r - redo the command.
- p - put(paste) text after the cursor.
- r+newcharacter - replace the old character at the cursor with the new character.
- ce - change until the end of the line.
- ctrl+g - show your location in the file and the file status.
- number+G - move to a line in the file.
- G - move to the bottom of the file
- gg - move to the start of the file.
- /phrase - search for the phrase
- n - search for the same phrase again
- N - search for the same phrase again in the opposite direction.
- ?phrase - search for a phrase in the backward direction.
- ctrl+o - go back to where you came from
- ctrl+i - goes forward
- % - find a matching ), ], }
- :s/new/old - subtitute first occurrence of new for old
- :s/new/old/g - subtitute new for old globally.
- :!externalCommand - execute an external command, eg: :!ls
- :w filename - save changes made to this file
- :!rm filename - remove file
- v - visual mode, visual selection
- :'<,'>w filename - write selected lines in visual mode to the file.
- :r filename - insert the contents of a file.
- :r :!ls - read the output of ls command and put it below the cursor.
- o - open a line below the cursor and place you in the Insert mode.
- O - open a line above the cursor and place you in the Insert mode.
- a - insert text after the cursor.
- R - replace more than one character, esc to leave the Replace mode.
- y - in Visual mode, copy the highlighted text.
- :set ic - in Search mode, set the ignore case option
- :set hls is - in Search mode, set hlsearch and incsearch option
- :set noic - in Search mode, disable ignore case option
- :help - open online help system
- ctrl+w ctrl+w - jump from one window to another
- :q - close the help window
- ctrl+d - see possible completion
- <TAB> - use one completion
reference: Vim cheat sheet: vim.rtorr.com/