Python repeat code in Vim

I need to wrap a block of code in a for loop. Since this is Python, I need to take care of the indentation and increase the number of tabs by one. Any easy way to do this in Vim?

+5
source share
5 answers

Try clicking Vfor visual line mode, select the area you want to indent, and click >. Other movements, except V, are also good.

+3
source

You can manually adjust the indent with <and >, and = =the code block will automatically indent .

In addition, Python Indentation with Vim can help with more advanced automatic indentation.

, ] p - , ( , for, ] p).

+3

.

+1

, , - v i p > , . V I nside P, - .

0

, ~/.vimrc:

vnoremap < <gv
vnoremap > >gv

, ( v), > <, .

vim , :

set autoindent
set smartindent

, , .

You can enable / disable the insert mode using the key displayed as follows:

set pastetoggle=<F6>

It F6will now switch in insert mode so that you can paste text without automatic recharge.

0
source

All Articles