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?
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 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.
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.
Enter visual mode ( ctrl + v) jj to select the lines. shift + i to go into insert. Delete 2 spaces ( with backspace or delete)
Type Ctrl-D on your keyboard, removes one tabstop at a time, works for space-replaced tabs.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With