Vim / Neovim
Enable Italics in Vim
add
highlight Comment cterm=italic
to .vimrc (after the colorscheme declaration).If using nanotech/jellybeans.vim colorscheme, make sure to add
let g:jellybeans_use_term_italics = 1
too.
Buffers
:ls
- see a list of current buffers.:e ../file.txt
- open ../file.txt.:b file
- switch between all open files.:b#
- open last visited file.
Tabs (I use tmux, not needed anymore)
:tabs
- list all tabs including their displayed windows.:tabm 0
- move current tab to first.:tabm
- move current tab to last.:tabn
- go to next tab.:tabp
- go to previous tab.:tabfirst
- go to first tab.:tablast
- go to last tab.
In Normal mode:
gt
- go to next tab.gT
- go to previous tab.{i}gt
- go to tab in positioni
.
Command Mode
:earlier 10m
- time travel in time to 10 minutes ago inside Vim.:later 10m
- time travel in time to 10 minutes later inside Vim.:norm Ibegin
- go to the beginning of a line and enterbegin
, then repeat across all selected lines.!pwd
- runpwd
terminal command from vim.:read date
- insert the output ofdate
command in current line.:30read date
- insert the output ofdate
command in line 30.:$read date
- insert the output ofdate
command in the last line.
:10,15s/old/new/g
- substitute all occurences ofold
withnew
from line 10 to 15.:.,.+5s/old/new/g
- substitute all occurences ofold
withnew
from the current line to the next 5 lines.:g/import/d
- delete all lines including the wordimport
.:g!/import/d
- delete all lines not including the wordimport
.:g/^@/m$
- move all lines starting with@
to the end of the document.
Working with splits
:split
/:sp
- horizontal split.:10sp
- 10 lines high horizontal split.<ctrl> w _
- maximize a horizontal split.<ctrl> w =
- equalize splits.:resize +5
/:res +5
- increase a split height by 5 lines.
:vsplit
/:vs
- vertical split.<ctrl> w |
- maximize a vertical split.<ctrl> w =
- equalize splits.:vertical resize +5
/:vert res +5
- increase a split height by 5 lines.
<ctrl> w c
- close a split.<ctrl> w R
- swap splits.
Miscellaneous
:set wrap
/:set nowrap
- Default
leader
is\
(I map to it to<space>
/,
) <CR>
(aka carriage/cartridge return) meansEnter
/Return
.- Alternative to
<ESC>
:<C-[>
(I map<ESC>
tojj
/jk
) :smile