Skip to content

Commit

Permalink
Merge 9f15226 into 6e3f471
Browse files Browse the repository at this point in the history
  • Loading branch information
leslie-qiwa committed Jan 8, 2018
2 parents 6e3f471 + 9f15226 commit 3e2f233
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 0 deletions.
1 change: 1 addition & 0 deletions cheatsheets/git.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ Undo all commits after = git reset 'commit'
Add a remote upstream repo = git remote add upstream <URL>
Sync with remote upstream repo = git pull upstream master
Append new commit to keep single commits = git commit -a --amend
List branches of remote repo = git branch -r
159 changes: 159 additions & 0 deletions cheatsheets/vim.ini
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

0 comments on commit 3e2f233

Please sign in to comment.