Skip to content

Instantly share code, notes, and snippets.

@aiafrasinei
Created February 5, 2019 15:54
Show Gist options
  • Save aiafrasinei/517b1508e7e5b0b1b02e53b9326e768e to your computer and use it in GitHub Desktop.
Save aiafrasinei/517b1508e7e5b0b1b02e53b9326e768e to your computer and use it in GitHub Desktop.
vim usefull commands
-----------
Visual mode
-----------
v
y - yank
p - paste
select text << >> - indentation
d - delete marked text
~ - switch case
-----------
Insert mode
-----------
a - append
Shift A - append at end of line
i - insert
Shift I - append to start of line
o - add newline after current line and insert mode
O -add newline before current line and insert mode
-------------
Moving around
-------------
H,M,L - top screen,middle screen, bottom screen
gg - top of file
G - bottom of file
$ - go to end of line
^ - go to first non empty character of line 0 - go to start of line
% - go to next bracket
e - jump forward by words
b - jump backwards by words
m x - make mark
' x - go to mark
marks - list marks
------------
delete stuff
------------
x - delete letter
dw - delete word
dd - delete line
number dd - delete number of lines
--------------
search/replace
--------------
/
? search backward
:[range]s/search/replace/
:%s/search/replace/g - search/replace all file
:%s/search/replace/gc - for confirmations
C
---------
undo redo
---------
u - undo
Cntrl r - redo
----
exit
----
:w - write (save) the file, but don't exit
:wq - write (save) and quit
:q - quit (fails if anything has changed)
:q! - quit and throw away changes
--------------
multiple files
--------------
:e filename
:bn - next buffer
:bp - previous buffer
:bd - buffer delete
:buffers - list buffers
--------------
folding
--------------
visual mode - create fold zf
- open fold zo
K open man file for current word
hex mode :%!xxd
convert back :%!xxd -r
ctags -R
Control ] go function definition
Control T go back
----------
usual vimrc
colorscheme elflord
set tabstop=4
set expandtab
set shiftwidth=4
set wildchar=<Tab> wildmenu wildmode=full
syntax on
---------
nnoremap <F5> :buffers<CR>:buffer<Space>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment