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:
position cursor in first line indented
enter visual mode typing shift + v
move down, typing j until reach last line indented (alternately can type line # + g if know line number of last line indented).
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
Post a Comment