StatsSorceress
StatsSorceress

Reputation: 3099

Vim: unindent multiple lines to the beginning

Suppose I have something like this:

line 1 with text
    line 2 with text
         line 3 with text
              line 4 with text

I want to unindent all of these lines to the beginning, like this:

line 1 with text
line 2 with text
line 3 with text
line 4 with text

Shift + V < gives me ONE level of un-indentation. How can I get them all to the beginning? Sorry, I'm having trouble phrasing this...

Upvotes: 0

Views: 1081

Answers (1)

DJMcMayhem
DJMcMayhem

Reputation: 7669

There are two different ways you could do this:

  1. Visually select all of the lines, press <, and then press . as many times as you need until there is no indent left. Or if there are a specific number of lines you would like this on, you could do something like

    • 5<< (unindent 5 lines)

    • <j (unindent this line and the next)

    • <ip (unindent inside this paragraph)

    followed by as many . as you need.

  2. Select all of the lines, and then type either :norm d^ or :s/^\s*

Also, Shift-V + V + < is basically the same as <<.

Upvotes: 4

Related Questions