eskp.net


Various VIM tricks

Delete all trailing whitespace

:%s/\s\+$//

And delete all leading

:%s/^\s\+

Add text at the end of each line

:%s/$/text/

Align the columns

:%!column -t

Replace a character with a new line

:%s/*/\r/

Increment all numbers by 1

:let g:I=1
:%g/<match this number="\d"/ s/\d\+/\=g:I/|let g:I=g:I+1

Paste a column after a different column

Use visual block (ctrl-v) to cut the second column. Then move to the end of the first line of the first column and paste the yanked column.

Save readonly file with sudo

:w !sudo tee %