Created
February 14, 2020 12:49
-
-
Save gawen/003b5d7da386ed2cc84d42d6f94bc63c to your computer and use it in GitHub Desktop.
VIM cheatsheet
This file contains hidden or 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
i: interactive mode | |
v: visual mode | |
escape to go back to no mode | |
# classic commands | |
:e <filename>: open <filename> in current window | |
:e **/<filename>: fuzzy search for <filename> | |
:w [<filename>]: write current window | |
:q: quit | |
suffix 'a' for all files | |
:wqa: write every file and quit | |
:w!: force writing even if file changed | |
# copy/paste | |
yy: copy current line | |
dd: cut current line | |
p: paste default buffer | |
"ap: paste register 'a' | |
in visual mode, | |
y: copy current selection | |
d: cut current selection | |
"ay: copy current selection in register 'a' | |
"ad: cut current selection in register 'a' | |
Special register: '+', which is the system clipboard | |
"+y: copy current selection in system clipboard | |
"+p: ... | |
"+d: ... | |
# search & replace | |
/<expr>: search for expression | |
*: search for current expression under cursor | |
n: next match | |
shift+n: previous match | |
:%s/<before>/<after>/g: replace regexp <before> by <after> in current file | |
:%g/<expr>/d: delete every line with regexp <expr> | |
# window | |
:new: open horizontal window | |
:vnew: open vertical window | |
# cli | |
:!<bash>: run <bash> in terminal | |
:r!<bash>: run <bash> in terminal and pipe output to current buffer | |
# protips | |
ctrl+wF: open filepath which is under current cursor | |
:r!rg <expr>: search for <expr> in all your files and print in your current buffer (after a :new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment