
VIM常用命令
不知道发啥,发quick note里的第一篇作为新手任务。
concatenate strings
%s/^/('/ | %s/$/'),/ | %s/\n//g | %s/,$//
%s/^/'/ | %s/$/',/ | %s/\n//g | %s/,$//
%s/^\n$//g|%s/$/‘,/|%s/^/‘/|%s/\n//g|s/,$//
replace pattern
1,$s/\(hello.\)\(world.\)/\2\1\0/
\1 : first matched pattern: hello.*
\2: second matched pattern : world.*
\0: the whole pattern
.s/(\([0-9]*\))/{\1}/
\1: the matched pattern in ()
\0: the whole pattern
w !sudo tee %
remove duplicated new line
%s/^\n$//g
remove new line
%s/\n//g
remove empty line
g/^$/d
remove lines start with #:
g/^#.*$/d
remove duplicated line
:sort
:g/^\(.*\)$\n\1$/d
remove duplicated spaces
:%s/\s\s*/ /g
remove line without xxx
:v/xxx/d
select registers
"a
system clipboard
"+
recording a macro
q
running a macro
@
Comment…