delete all line match pattern
:g/pattern/d
delete all lines not match pattern
:g!/pattern/d
:v/pattern/d
VIM 中强大的 g 命令
copy all match lines to the end of file
:g/pattern/t$
move all match lines to the end of file
:g/pattern/m$
copy all lines matching pattern to register ‘a’
qaq:g/pattern/y A
some other useges:
:2,8co15 "copy lines 2 through 8 after line 15
:4,15t$ "copy lines 4 through 15 to end of document (t == co)
:-t$ "copy previous line to end of document
:m0 "move current line to line 0 (i.e. the top of the document)
:.,+3m$-1 "current line through current+3 are moved to the lastLine-1 (i.e. next to last)