It ought to beryllium trivial, and it mightiness equal beryllium successful the aid, however I tin't fig retired however to navigate it. However bash I indent aggregate traces rapidly successful vi?
Usage the > bid. To indent 5 strains, 5>>. To grade a artifact of strains and indent it, Vjj> to indent 3 strains (Vim lone). To indent a curly-braces artifact, option your cursor connected 1 of the curly braces and usage >% oregon from anyplace wrong artifact usage >iB.
If you’re copying blocks of matter about and demand to align the indent of a artifact successful its fresh determination, usage ]p alternatively of conscionable p. This aligns the pasted artifact with the surrounding matter.
Besides, the shiftwidth
mounting permits you to power however galore areas to indent.
This reply summarises the another solutions and feedback of this motion, and it provides other accusation primarily based connected the Vim documentation and the Vim wiki. For conciseness, this reply doesn't separate betwixt Vi and Vim-circumstantial instructions.
Successful the instructions beneath, "re-indent" means "indent strains in accordance to your indentation settings." shiftwidth
is the capital adaptable that controls indentation.
Broad Instructions
>> Indent line by shiftwidth spaces<< De-indent line by shiftwidth spaces5>> Indent 5 lines5== Re-indent 5 lines>% Increase indent of a braced or bracketed block (place cursor on brace first)=% Reindent a braced or bracketed block (cursor on brace)<% Decrease indent of a braced or bracketed block (cursor on brace)]p Paste text, aligning indentation with surroundings=i{ Re-indent the 'inner block', i.e. the contents of the block=a{ Re-indent 'a block', i.e. block and containing braces=2a{ Re-indent '2 blocks', i.e. this block and containing block>i{ Increase inner block indent<i{ Decrease inner block indent
You tin regenerate {
with }
oregon B
, e.g. =iB
is a legitimate artifact indent bid. Return a expression astatine "Indent a Codification Artifact" for a good illustration to attempt these instructions retired connected.
Besides, retrieve that
. Repeat last command
, truthful indentation instructions tin beryllium easy and conveniently repeated.
Re-indenting absolute records-data
Different communal occupation is requiring indentation to beryllium mounted passim a origin record:
gg=G Re-indent entire buffer
You tin widen this thought to aggregate records-data:
" Re-indent all your C source code::args *.c:argdo normal gg=G:wall
Oregon aggregate buffers:
" Re-indent all open buffers::bufdo normal gg=G:wall
Successful Ocular Manner
Vjj> Visually mark and then indent three lines
Successful insert manner
These instructions use to the actual formation:
CTRL-t insert indent at start of lineCTRL-d remove indent at start of line0 CTRL-d remove all indentation from line
Ex instructions
These are utile once you privation to indent a circumstantial scope of strains, with out shifting yourcursor.
:< and :> Given a range, apply indentation e.g.:4,8> indent lines 4 to 8, inclusive
Indenting utilizing markers
Different attack is through markers:
ma Mark top of block to indent as marker 'a'
...decision cursor to extremity determination
>'a Indent from marker 'a' to current location
Variables that govern indentation
You tin fit these successful your .vimrc record.
set expandtab "Use softtabstop spaces instead of tab characters for indentationset shiftwidth=4 "Indent by 4 spaces when using >>, <<, == etc.set softtabstop=4 "Indent by 4 spaces when pressing <TAB>set autoindent "Keep indentation from previous lineset smartindent "Automatically inserts indentation in some casesset cindent "Like smartindent, but stricter and more customisable
Vim has clever indentation primarily based connected filetype. Attempt including this to your .vimrc:
if has ("autocmd") " File type detection. Indent based on filetype. Recommended. filetype plugin indent onendif
References
Mistake producing weblog contented
A New Git Diff Algo
A New Git Diff Algo from Youtube.com