Skip to content

Instantly share code, notes, and snippets.

@filipenos
Last active January 27, 2017 13:12
Show Gist options
  • Save filipenos/3a3895e53dfe866d279c to your computer and use it in GitHub Desktop.
Save filipenos/3a3895e53dfe866d279c to your computer and use it in GitHub Desktop.
My vim tips
# Modes
<ESC> "normal
v "visual
V "visual-line
<CTRL> + v "visual-block
i "insert
I "insert (insert in first pos) (0+i)
a "insert after
A "insert (insert in last pos) ($+a)
s "insert (remove actual char and insert mode)
S "insert (remove line and insert mode)
r "replace (remove actual char)
R "replace
"Especial chars
c "cut
y "copy
x "delete
i "insise
v "visual
w "word
. "repeat last command
"Text
:noh "Clean last search
"Find
f <key> "go to key on line
:grep "find
:cnext "next result
:cprevious "previous result
"Buffers
:ls "list buffers
:bw "close buffer
:<n>b "go to buffer
"Tools
:diffget <n>"apply diff on <n>
"Erros
:lnext "next error ocurrence
:lprev "previous error ocurrence
"Extras
CTRL + l "clear cache
CTRL + G "show current file on status
#Collapse/Expand HTML Tags
zfat or zfit "to fold a tag
za "to toggle tag
zR "opens all folds in current document
#Macros
q <key> "start macro record, all commands are saved
@ <key> "execute macro
@@ "execute last macro
"Editing 'modo normal'
d + i + <delimiter> "delete everything inside the delimiter
<number> + i + <text> + ESC "repeat typed text
J "remove \n
0 "move to start line
$ "move to end line
b "move to start word
e "move to end word
w "next word
W "next word ignone especial chars
viw "select the word under the cursor
daw "delete the word under the cursor
caw "delete the word under the cursor and put you in insert mode
"Editing 'modo visual'
u "lowercase
U "uppercase
" edit with plugin tpope/vim-surround
"surrounds ", ', (, [, {
"tags are surrounds too, ex <p> <em> <b>
cs <old><new> "change surround ex: cs"', cs{[
ds <surround> "remove surround ex: ds"
vS <surround> "add surround on selection
VS <surround> "add surround in line
"Sites and wiks
http://vim.wikia.com/wiki/Replace_a_word_with_yanked_text
http://vim.wikia.com/wiki/Using_vim_as_calculator
http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim?rq=1
"apply macros on line ranges
http://stackoverflow.com/questions/390174/in-vim-how-do-i-apply-a-macro-to-a-set-of-lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment