vim: delete the first 2 spaces for multiple lines
You could also use a search and replace (in the ex editor, accessed via the : character):
Remove first two characters no matter what:
%s/^.\{2}//
Remove first two white space characters (must be at the beginning and both must be whitespace... any line not matching that criteria will be skipped):
%s/^\s\{2}//
- Enter visual block mode with
Ctrl-V
(orCtrl-Q
if you useCtrl-V
for paste); - Select the area to delete with the arrows;
- Then press
d
to delete the selected area. - Press
Esc
Assuming a shiftwidth=2
, then using shift with a range of %
:%<
Some more options. You can decided which is the "easiest way".
Remove the first 2 characters of every line:
:%normal 2x
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 <<