![Indent Indent](/uploads/1/2/5/4/125465390/384135503.gif)
![Indent Indent](http://www.techbeatly.com/wp-content/uploads/2018/06/setup-your-vim-editor-for-ansible-playbook.png)
The auto-indent is based on the current syntax mode. I know that if you are editing Foo.java, then entering a and hitting Enter indents the following line. As for tabs, there are two settings. Within Vim, type a colon and then 'set tabstop=4' which will set the tabs to display as four spaces. Use the command. To indent 5 lines, 5.To mark a block of lines and indent it, Vjj to indent 3 lines (vim only). To indent a curly-braces block, put your cursor on one of the curly braces and use % or from anywhere inside block use iB. 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.
I, which gives a few interesting things you didn't ask about. To automatically indent braces, use::set cindentTo indent two spaces (instead of one tab of eight spaces, the vim default)::set shiftwidth=2To keep vim from converting eight spaces into tabs::set expandtabIf you ever want to change the indentation of a block of text, use.
I usually use this in conjunction with block-select mode (v, select a block of text, ).(I'd try to talk you out of using two-space indentation, since I (and most other people) find it hard to read, but that's another discussion.). A lot of vim's features (like autoindent and cindent) are turned off by default. To really see what vim can do for you, you need a decent /.vimrc.A good starter one is in $VIMRUNTIME/vimrcexample.vim. If you want to try it out, use:source $VIMRUNTIME/vimrcexample.vimwhen in vim.I'd actually suggest just copying the contents to your /.vimrc as it's well commented, and a good place to start learning how to use vim. You can do this by:e $VIMRUNTIME/vimrcexample.vim:w!
/.vimrcThis will overwrite your current /.vimrc, but if all you have in there is the indent settings Davr suggested, I wouldn't sweat it, as the example vimrc will take care of that for you as well. For a complete walkthrough of the example, and what it does for you, see:help vimrc-intro.