Commands Flashcards
Increase number by 10
10<C-a>
Decrease number by 5
5<C-x>
Insert mode:
Delete one character (backspace)
<C-h>
Insert mode:
Delete back one word
<C-w>
Insert mode:
Delete back to start of line
<C-u>
Insert mode:
Switch to Normal mode
<Esc> or <C-[>
Insert mode:
Switch to Insert Normal Mode
<C-o>
Redraw screen with the current line in the middle of the window
zz
Join current and next line together
J
Look up man page for the word under cursor
K
Insert mode:
Result of 7*67
<C-r>=7*67<CR>
Switch to character-wise Visual mode
v
Switch to line-wise Visual mode
V
Switch to block-wise Visual mode
<C-v>
Reselect the last visual selection
gv
Visual mode:
Go to other end of highlighed text
o
Make {motion} text uppercase.
gU{motion}
Make current line uppercase
gUgU or gUU
Make {motion} text lowervase
gu{motion}
Switch case of the current line
g~~
how to choose area for Ex mode limit
After selecting area in visual mode, just press : to limit next command to this selection only. Super useful for find and replace etc.
Repeat the last Ex command
@:
Ex mode:
Copy current word under cursor into command line
<C-r><C-w>
Open the command-line window with history of Ex commands
q:
Open the command-line window with history of searches
q/
Execute program in shell
:!{program}
Command mode:
Current file path
%
Suspend current Vim session and enter terminal
Ctrl-z
Return back to suspended job from terminal
fg
Pass the contents of the buffer as standard input to the external {cmd} command
:write !{cmd}
Read the contents of external {cmd} command into current buffer
:read !{cmd}
Sort current buffer from 2nd row onwards, delimiter by ,
and use second column as sort key
:2,$!sort -t’,’ -k2
Difference between buffer and file
Buffer are in-memory representation of file, while files are saved to disk.
List current buffers
:ls
Next buffer
:bnext
Toggle between current and alternative buffer
<C-^>
Print list of Vim args
:args
Next and Previous argument
:next and :prev