indentation - autoindent in vim for selected text -


1) there anyway autoindent/retab on set of lines, rather entire file?

set shiftwidth=4 set expandtab set tabstop=4  

has been defined in .vimrc.

what want select bunch of lines , apply indentation on them. because file large , want clean line of codes. doing :retab, have force whole file reindented.

for example select following code , reindent automatically

def hello(self):  line1  line2 

to

def hello(self)     line1     line2 

2) there way can reverse tab? shift-tab in eclipse. goes 4 spaces.

what want select bunch of lines , apply indentation on them

you can apply indentation lines in visual mode. follow these steps:

  1. position cursor in first line indented

  2. enter visual mode typing shift + v

  3. move down, typing j until reach last line indented (alternately can type line # + g if know line number of last line indented).

  4. type >

another solution regex in command-line mode:

2,5s/\v(.*)/\t\1/g

here line range specified in first 2 numbers of regex (in case line 2 5).


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -