Should be trivial, and it might even be in the help, but I can't figure out how to navigate it.
Thanks in advance.
Should be trivial, and it might even be in the help, but I can't figure out how to navigate it.
Thanks in advance.
Use the > command. To indent 5 lines, 5>>. To mark a block of lines and indent it, Vjjj> to indent 3 lines (vim only). To indent a curly-braces block, put your cursor on one of the curly braces and use >%.
If you're copying blocks of text around and need to align the indent of a block in its new location, use ]p instead of just p. This aligns the pasted block with the surrounding text.
In addition to the answer already given and accepted, it is also possible to place a marker and then indent everything from the current cursor to the marker. Thus, enter ma
where you want the top of your indented block, cursor down as far as you need and then type >'a
(note that "a
" can be substituted for any valid marker name). This is sometimes easier than 5>>
or vjjj>
.
As well as the offered solutions, I like to do things a paragraph at a time with >}
Also try this for "C-indenting" indentation, do ":help =" for more info:
={
That will auto-indent the current code block you're in.
Or just:
==
to auto-indent the current line.
:help
is your friend. Use hjkl
to move the cursor, CTRL-]
in :help
to jump to a term's help entry, CTRL-SHIFT-O
to jump back. See :help >
for your question.
Key-Presses for more visual people:
[Escape] # Enter Command Mode
# move around to the start of the area to indent
[h][j][k][l][up][down][left][right]
[v] # start a block
# move around to the end of the area to indent
[h][j][k][l][up][down][left][right]
[0..9] # ( Optional ) Type the Number of indentation levels you want
[>] # execute the indentation on the block
A big selection would be
gg=G
it is really fast, and everything gets indented ;-)
when you select a block and use > to indent, it indents then goes back to normal mode. I have this in my .vimrc :
vnoremap < <gv
vnoremap > >gv
It lets you indent your selection as many time as you want.
do this $vi .vimrc and add this line autocmd FileType cpp setlocal expandtab shiftwidth=4 softtabstop=4 cindent
this is only for cpp file you can do this for another file type also just by modifying the filetype...