Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to unindent in vim without leaving edit mode?

Tags:

vim

I'm writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block. Normally I can just type << to unindent, but it takes too many keystorkes, anyone have a better idea?

like image 829
FurtiveFelon Avatar asked Nov 15 '09 22:11

FurtiveFelon


People also ask

How do I Unindent a block of code in Vim?

In normal mode, press Tab or Shift-Tab to adjust the indent on the current line and position the cursor on the first nonblank character; in insert mode, press Shift-Tab to unindent; in visual mode, press Tab or Shift-Tab to adjust the indent on selected lines.

How do I Autoindent in Vim?

How to Turn On Auto Indent in Vim. To automatically indent when editing a file in Vim, enable the auto indenting feature using the :set autoindent flag in command mode: Press Enter, and this will auto-indent the file you are currently editing.

How do I tab a section in Vim?

Using Command “>”: You need to open the visual block mode first for indentation, using the “ctrl+v” shortcut. After that, press the “next” button to select the number of characters to be indented and press “j” to cover the lines to tab along, i.e., 2 to 4.

How do you backspace multiple lines in Vim?

Enter visual mode ( ctrl + v) jj to select the lines. shift + i to go into insert. Delete 2 spaces ( with backspace or delete)


2 Answers

Type Ctrl-D on your keyboard, removes one tabstop at a time, works for space-replaced tabs.

like image 81
Evgeny Avatar answered Sep 23 '22 17:09

Evgeny


In Vim in Linux you can unindent multiple lines by using V to select your first line. Press the down arrow to select multiple lines. Then type < to unindent all of the lines.

If you want to indent, type > instead

like image 35
Viragos Avatar answered Sep 23 '22 17:09

Viragos