Friday, December 26, 2014

Goodbye line numbers.

Ever copy code into vim and realize that the line numbers were also copied. Here is a quick easy way to get rid of the line numbers.

Original code:

We want to remove the first 5 characters from every line so then we need to use the normal option:

:%normal 5x

Press return and the line numbers are gone!

Some other tricks:

Remove first 2 characters of every line, only if they're spaces:
:%s/^ /

Note that the last slash is optional, and is only here so that you can see the two spaces. Without the slash, it's only 7 characters, including the :.

Move indentation to left for every line:
:%normal <<

No comments:

Post a Comment