Reference:
- http://blog.csdn.net/love__coder/article/details/6739670
- http://blog.csdn.net/love__coder/article/details/7217377
Intercept to generate a new file or append to an existing file:
:up to aw!./new.txt #将第21 ~42 line to generate new.txt under the same path:Max,w! >>./ AnotherNew.txt #将第43 ~52 Row appended to anotherNew.txt under T same path
Replace:
: s/old/New #替换当前行的第一个old为new: s/old/new/g #替换当前行的所有的old为new:., $s/old/New # Replace the current line to the first old of the last row for new:., $s/old/new/g #替换当前行到最后行的所有old为new: N,ms/old/New # Replace the nth row to the first old of row m of New:n,ms/old/new/g #替换第N行到第M行的所有old为new: N,ms/old/new/GC # Replace all old of row N to line m with new, and ask for the deletion individually:%s/old/new #替换所有行的第一个old为new:%s/old/new/g # Replace all old for all rows with new
Vim replacement, interception, and append operations