Indenting text in a file with vi/vim
If you want to indent all the text by one tab stop using vi or vim load the text file into vi and type
:1,$s/^/{tab}/
where {tab} is CTRL-V CTRL-I. This command says from line 1 to last line ($) subsitute (s) the beginning of line (^) with a TAB character.
You can also do things like move to the first line of a block and indent 5 lines using:
:.,.+4s/^/{tab}/
The . means current line and .+4 means current line plus 4 more (1 + 4 = 5).
Written by Darrell Grainger
Related protips
1 Response
Better idea is to select text to indent and use >>
, =
or :retab
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#