UP | HOME

Several VIM commands learned today

Substitute words
:s/From/To/g
:%s/From/To/g
/g means substitute all happens in the line.
%s means means affect all lines in the file.

Split window
:split
:split file-name ->open a second window and starts editing the file
:vsplit -> vertical splits
CTRL-W w -> jump between windows
vim -o one.txt two.txt three.txt -> open a window for each file

CTRL-V : block visual mode
SHIFT-V : select a line
Y : copy a line
y : copy selected
P : insert parse
p : appending parse

Tab pages
:tabedit file-name
gt, gT -> navigate between tabs

w, e, b W, E, B ^, $

Move to a single character. A litter different between ’f’ and ’t’.
fx, Fx, 3fx (’f’ means ’find’)
tx, Tx, 3tx (’t’ means ’to’)

Match a parenthesis
%

Move line
g, G, gg, H, M, L

Simple search
/pattern
n,N -> navigate between search results
:set hlsearch -> highlight search results