Quantcast
Viewing all articles
Browse latest Browse all 5

Answer by Shawn J. Goff for Block editing *live* in Emacs or Vim

In vim, the typical way to delete the first n characters is to do something like :%s/.\{0,6\}//.

% will do the whole document; you can replace that with a selection or with the actual lines you care about. The s command is for "substitute". It will replace a regular expression with whatever you give it, and it will only match once on each line unless you add a specific option. The / is a delimiter - this can be any character, but / is usually used unless it is advantageous to use something else (so you don't have to escape / in the rest of the command). The argument after the first delimiter is a regular expression that will be used to find matching strings in your selection. The argument after the second delimiter is what the match will be replaced with.

So this command says find 0 to 6 instances of any character, and replace them with nothing.


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>