Indentation And Format Code In Vim

Thu Nov 12 2020

indentation

basics

press v to enter selection mode, then…

indent

  • indent by default configuration: >
  • indent 4 spaces: 4 >

unindent

  • unindent by default configuration: <
  • unindent 4 spaces: 4 <

indent selected lines

  • use v command to enter select mode, select lines you want to indent
  • indent selected lines: j j >

v j j >

indent particular lines

Example is set to 5 lines

5 > >

references

format code

configure indent size

add configurations to ~/.vimrc

conf
|
:set shiftwidth=2 :set autoindent :set smartindent :set tabstop=2

command

g g = G

references