set file language for highlighting
:set filetypewill show current language used for syntax highlighting.)
zf#j creates a fold from the cursor down # lines. zf/string creates a fold from the cursor to string . zj moves the cursor to the next fold. zk moves the cursor to the previous fold. zo opens a fold at the cursor. zO opens all folds at the cursor. zc close a fold at the cursor. zm increases the foldlevel by one. zM closes all open folds. zr decreases the foldlevel by one. zR decreases the foldlevel to zero -- all folds will be open. zd deletes the fold at the cursor. zE deletes all folds. [z move to start of open fold. ]z move to end of open fold.
- global vimrc:
- user vimrc
- use other file: in .vimrc add
split and tabs
from command line:
from normal mode:
s-> split horizontally
v-> split vertically
q-> close split
ctrl+w-> switch to next window
j(moves to adjacent window, you can use hjkl for move direction)
switch splits orientation
- from horizontally to vertically:
- from vertically to horizontally:
switching case of characters
- Toggle case
g~then a movement.
gUthen a movement.
guthen a movement.
clear last search highlighting
turn of highlighting until next search
or turn off highlighting completly:
or, toggle it:
set hlsearch! nnoremap <F3> :set hlsearch!<CR>
to change a JSON file into a human-readable format, just write:
:%!python3 -m json.tool
Using vim as diff tool
vim -d <file1> <file2> or
vimdiff <file1> <file2>.
vimdiff basic commands:
dp diffput: puts changes under the cursor into the other file making them identical (thus removing the diff). do diffget: (o => obtain). The change under the cursor is replaced by the content of the other file making them identical. ]c Jump to the next diff [c Jump to the previous diff
:diffthis command to initiate a diff when Vim is already running.
Reload changed content of file opened in Vim
Use the command
:e) command without specifying a file name to reload the current file. If you made changes to the file use
:e!) to force the reload.
in addition to manual refreshing, you can add
:set autoread in the