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}//

  1. Enter visual block mode with Ctrl-V (or Ctrl-Q if you use Ctrl-V for paste);
  2. Select the area to delete with the arrows;
  3. Then press d to delete the selected area.
  4. 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 <<

Tags:

Vim