golb

Vim && Neovim

Survival

Moving cursor

# move cursor
h j k l

# move relative
8j
# will move 8 line down

G # go to last line
gg # go to first line
5G # go to line 5


w  # move to beginning of next word
b  # move to previous beginning of word
e  # move to end of word
W  # move to beginning of next word after a whitespace
B  # move to beginning of previous word before a whitespace
E  # move to end of word before a whitespace

0  # move to beginning of line
$  # move to end of line
_  # move to first non-blank character of the line
g_ # move to last non-blank character of the line
f<char> # to next <char> cursor is on <char> (same line)
F<char> # to previous <char> cursor is on <char> (same line)
t<char> # to next <char> cursor is before (same line)
F<char> # to previous <char> cursor is after (same line)

% # jump to bracket pair

Moving cursor

Normal mode and insert mode

Shortcuts Normal mode

Selection

Files

# open/create file in new tab
:new filename.ext

# open/create file in new vertical split
:vert new filename.ext
# switch between splits
CTRL-w h
CTRL-w j
CTRL-w k
CTRL-w l
# copy full file
:%y+

# paste
"P+
# read and insert a file
:r file.txt

# launch shell commands
:!echo 1

# launch shell commands and capture output in the file
:r! echo 1
# will insert 1
# sort a file
1G!Gsort

System clipboard

You should have a clipboard util like xclip installed

Registers

# view the registers
:registers

Macros

q<register><commands>q

# then to play it
@<register>
# then
@@

Commands

# to replace
:%s/toto/tata/g

# to wrap lines
:set nowrap
:set wrap

Format json

# select the json with shift + V then run
# to prettify
:!jq

# to uglify
:!jq -c

Windows

Comment