-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
[main] | ||
name=vim | ||
desc=vim cheat sheet from https://vim.rtorr.com | ||
[global] | ||
open help for keyword = :help keyword | ||
open file = :o file | ||
save file as = :saveas file | ||
close current pane = :close | ||
open man page for word under the cursor = K | ||
|
||
[cursor] | ||
move cursor left = h | ||
move cursor right = l | ||
move cursor up = k | ||
move cursor down = j | ||
move to top of screen = H | ||
move to middle of screen = M | ||
move to bottom of screen = L | ||
jump forwards to the start of a word = w | ||
jump forwards to the start of a word (words can contain punctuation) = W | ||
jump forwards to the end of a word = e | ||
jump forwards to the end of a word (words can contain punctuation) = E | ||
jump backwards to the start of a word = b | ||
jump backwards to the start of a word (words can contain punctuation) = B | ||
move to matching character (default supported pairs: '()', '{}', '[]' - use :h matchpairs in vim for more info) = %% | ||
jump to the start of the line = 0 | ||
jump to the first non-blank character of the line = ^ | ||
jump to the end of the line = $ | ||
jump to the last non-blank character of the line = g_ | ||
go to the first line of the document = gg | ||
go to the last line of the document = G | ||
go to line 5 = 5G | ||
jump to next occurrence of character x = fx | ||
jump to before next occurrence of character x = tx | ||
jump to previous occurence of character x = Fx | ||
jump to after previous occurence of character x = Tx | ||
repeat previous f, t, F or T movement = ; | ||
repeat previous f, t, F or T movement, backwards = , | ||
jump to next paragraph (or function/block, when editing code) = } | ||
jump to previous paragraph (or function/block, when editing code) = { | ||
center cursor on screen = zz | ||
move back one full screen = Ctrl + b | ||
move forward one full screen = Ctrl + f | ||
move forward 1/2 a screen = Ctrl + d | ||
move back 1/2 a screen = Ctrl + u | ||
|
||
[cut & paste] | ||
yank (copy) a line = yy | ||
yank (copy) 2 lines = 2yy | ||
yank (copy) the characters of the word from the cursor position to the start of the next word = yw | ||
yank (copy) to end of line = ys | ||
put (paste) the clipboard after cursor = p | ||
put (paste) before cursor = P | ||
delete (cut) a line = dd | ||
delete (cut) 2 lines = 2dd | ||
delete (cut) the characters of the word from the cursor position to the start of the next word = dw | ||
delete (cut) to the end of the line = D or d$ | ||
delete (cut) character = x | ||
|
||
[Search and replace] | ||
search for pattern = /pattern | ||
search backward for pattern = ?pattern | ||
'very magic' pattern: non-alphanumeric characters are interpreted as special regex symbols (no escaping needed) = \vpattern | ||
repeat search in same direction = n | ||
repeat search in opposite direction = N | ||
replace all old with new throughout file = :%%s/old/new/g | ||
replace all old with new throughout file with confirmations = :%%s/old/new/gc | ||
remove highlighting of search matches = :noh | ||
|
||
[insert] | ||
insert before the cursor = i | ||
insert at the beginning of the line = I | ||
insert (append) after the cursor = a | ||
insert (append) at the end of the line = A | ||
append (open) a new line below the current line = o | ||
append (open) a new line above the current line = O | ||
insert (append) at the end of the word = ea | ||
|
||
[multiple] | ||
edit a file in a new buffer = e | ||
go to the next buffer = :bnext or :bn | ||
go to the previous buffer = :bprev or :bp | ||
delete a buffer (close a file) = :bd | ||
list all open buffers = :ls | ||
open a file in a new buffer and split window = :sp file | ||
open a file in a new buffer and vertically split window = :vsp file | ||
split window = Ctrl + ws | ||
switch windows = Ctrl + ww | ||
quit window = Ctrl + wq | ||
split window vertical = Ctrl + wv | ||
move cursor to the left window (vertical split) = Ctrl + wh | ||
move cursor to the right window (vertical split) = Ctrl + wl | ||
move cursor to the below window (horizontal split) = Ctrl + wj | ||
move cursor to the above window (horizontal split) = Ctrl + wk | ||
|
||
[edit] | ||
replace a single character = r | ||
join line below to the current one with one space in between = J | ||
join line below to the current one without space in between = gJ | ||
change (replace) entire line = cc | ||
change (replace) to the end of the word = cw | ||
change (replace) to the end of the line = c$ | ||
delete character and substitute text = s | ||
delete line and substitute text (same as cc) = S | ||
transpose two letters (delete and paste) = xp | ||
undo = u | ||
redo = Ctrl + r | ||
repeat last command = . | ||
|
||
[visual mode - mark text] | ||
start visual mode, mark lines, then do a command (like y-yank) = v | ||
start linewise visual mode = V | ||
move to other end of marked area = o | ||
start visual block mode = Ctrl + v | ||
move to other corner of block = O | ||
mark a word = aw | ||
a block with () = ab | ||
a block with {} = aB | ||
inner block with () = ib | ||
inner block with {} = iB | ||
|
||
[visual command] | ||
shift text right = > | ||
shift text left = < | ||
yank (copy) marked text = y | ||
delete marked text = d | ||
switch case = ~ | ||
|
||
[Search in multiple files] | ||
search for pattern in multiple file = :vimgrep /pattern/ {file} e.g. :vimgrep /foo/ **/* | ||
jump to the next match = :cn | ||
jump to the previous match = :cp | ||
open a window containing the list of matches = :copen | ||
|
||
[register] | ||
show registers content = :reg | ||
yank into register x = "xy | ||
paste contents of register x = "xp | ||
|
||
[marks] | ||
list of mark = :marks | ||
set current position for mark A = ma | ||
jump to position of mark A = `a | ||
yank text to position of mark A = y`a | ||
|
||
[macros] | ||
record macro a = qa | ||
stop recording macro = q | ||
run macro a = @a | ||
rerun last run macro = @@ | ||
|
||
[Exiting] | ||
write (save) the file, but don't exit = :w | ||
write out the current file using sudo = :w !sudo tee %% | ||
write (save) and quit = :wq or :x or ZZ | ||
quit (fails if there are unsaved changes) = :q | ||
quit and throw away unsaved changes = :q! or ZQ | ||
write (save) and quit on all tabs = :wqa | ||