indent.txt ForVim version 9.2. Last change: 2026 Feb 14VIM REFERENCE MANUAL by Bram MoolenaarThis fileis about indentingC programs and other files.1. IndentingC style programsC-indenting2. Indenting byexpressionindent-expression==============================================================================1. IndentingC style programsC-indentingThe basics forC style indenting are explained insection30.2 of the usermanual.Vim hasoptions for automatically indentingC style program files. Manyprogramming languages including Java and C++ follow very closely theformatting conventions established with C. Theseoptions affect only theindent anddo not perform other formatting. There are additionaloptions thataffect other kinds offormattingas wellas indenting, seeformat-comments,fo-table,gq andformatting for the main ones.There are in fact four main methods available for indentation, each oneoverrides the previous ifitis enabled, or non-empty for'indentexpr':'autoindent'uses the indent from the previous line.'smartindent'is like'autoindent' but also recognizes someCsyntax toincrease/reduce the indent where appropriate.'cindent'Works more cleverly than the other two andis configurable todifferent indenting styles.'indentexpr'The most flexible of all: Evaluates anexpression to computethe indent ofa line. When non-empty thismethod overridesthe other ones. Seeindent-expression.The rest of thissection describes the'cindent' option.Note that'cindent' indenting does not work for every code scenario. Vimis notaC compiler:it does not recognize all syntax. One requirementisthat toplevelfunctions havea '{' in the first column. Otherwise they areeasily confused with declarations.These fiveoptionscontrolC program indenting:'cindent'Enables Vim to performC program indenting automatically.'cinkeys'Specifies which keys trigger reindenting ininsert mode.'cinoptions'Sets your preferred indent style.'cinwords'Defines keywords that start an extra indent in the next line.'cinscopedecls'Defines strings that are recognizedasa C++ scopedeclaration.If'lisp'is not on and'equalprg'is empty, the "="operator indents usingVim's built-in algorithm rather than calling an external program.Seeautocommand for how to set the'cindent' option automatically forC codefiles and resetit for others.cinkeys-formatindentkeys-formatThe'cinkeys' optionisastring that controls Vim's indenting in response totyping certain characters or commands in certain contexts.Note that this notonly triggers C-indenting. When'indentexpr'is not empty'indentkeys'isused instead. The format of'cinkeys' and'indentkeys'is equal.The defaultis "0{,0},0),0],:,0#,!^F,o,O,e" whichspecifies that indentingoccursas follows:"0{"if you type '{'as the first character ina line"0}"if you type '}'as the first character ina line"0)"if you type ')'as the first character ina line"0]"if you type ']'as the first character ina line":"if you type ':' aftera label orcase statement"0#"if you type '#'as the first character ina line"!^F"if you typeCTRL-F (whichis not inserted)"o"if you typea<CR> anywhere or use the "o" command (not ininsert mode!)"O"if you use the "O" command (not ininsert mode!)"e"if you type the second 'e' for an "else"at the start ofalineCharacters that can precede each key:i_CTRL-F!Whena '!' precedes the key, Vim will notinsert the key but willinstead reindent the current line. This allows you to defineacommand key for reindenting the current line.CTRL-Fis the defaultkey for this. Be careful if you defineCTRL-I for this becauseCTRL-Iis the ASCII code for<Tab>.*Whena'*' precedes the key, Vim will reindent the line beforeinserting the key. If'cinkeys' contains "*<Return>", Vim reindentsthe current line before openinga new line.0Whena zero precedes the key (but appears after '!' or'*') Vim willreindent the line only if the keyis the first character you type inthe line. When used before "=" Vim will only reindent the line ifthereis only whitespace before the word.When neither '!' nor'*' precedes the key, Vim reindents the line after youtype the key. So ';' sets the indentation ofa line which includes the ';'.Special key names:<>Angle brackets mean spelled-out names of keys. For example: "<Up>","<Ins>" (seekey-notation).^Letters preceded bya caret (^) arecontrol characters. For example:"^F"isCTRL-F.oReindenta line when you use the "o" command or when Vim opensa newline below the current one (e.g., when you type<Enter> ininsertmode).OReindenta line when you use the "O" command.eReindenta line that starts with "else" when you type the second 'e'.:Reindenta line whena ':'is typed whichis aftera label orcasestatement. Don't reindent fora ":" in "class::method" for C++. ToReindent for any ":", use "<:>".=wordReindent when typing the last character of "word". "word" mayactually be part of another word. Thus "=end" would cause reindentingwhen typing the "d" in "endif" or "endwhile". But not when typing"bend". Also reindent when completion producesaword that startswith "word". "0=word" reindents when thereis only whitespace beforethe word.=~wordLike =word, but ignore case.If you really want to reindent when you type 'o', 'O', 'e', '0', '<', '>','*', ':' or '!', use "<o>", "<O>", "<e>", "<0>", "<<>", "<>>", "<*>", "<:>" or"<!>", respectively, for those keys.For an emacs-style indent mode where lines aren't indented every time youpress<Enter> but only if you press<Tab>,I suggest::set cinkeys=0{,0},:,0#,!<Tab>,!^FYou might also want to switch off'autoindent' then.Note: If you change the current line's indentation manually, Vim ignores thecindent settings for that line. This prevents vim from reindenting after youhave changed the indent by typing<BS>,<Tab>, or<Space> in the indent orusedCTRL-T orCTRL-D.cinoptions-valuesThe'cinoptions' option sets how Vim performs indentation. The value afterthe option character can be one of these (Nis any number):NindentN spaces-NindentN spaces to the leftNsN times'shiftwidth' spaces-NsN times'shiftwidth' spaces to the leftIn thelist below,"N" representsa number of your choice (the number can be negative). Whenthereis an 's' after the number, Vim multiplies the number by'shiftwidth':"1s"is'shiftwidth', "2s"is two times'shiftwidth', etc. You can useadecimal point, too: "-0.5s"is minus halfa'shiftwidth'.The examples below assumea'shiftwidth' of 4.cino->>N Amount added for "normal" indent. Used aftera line that should increase the indent (linesstarting with "if", an opening brace, etc.). (default'shiftwidth').cino= cino=>2cino=>2s if (cond) if (cond) if (cond) { { { foo;foo; foo; } } }cino-eeN AddN to the prevailing indent insidea set of braces if the opening braceat the End of the line (more precise:is not the first character ina line). Thisis useful if you wanta different indent when the '{'isat the start of the line from when '{'isat theend of the line. (default 0).cino= cino=e2cino=e-2 if (cond) { if (cond) { if (cond) { foo; foo; foo; } } } else else else { { { bar; bar; bar; } } }cino-nnN AddN to the prevailing indent fora statement after an "if", "while", etc., ifitis NOT insidea set of braces. Thisis useful if you wanta different indent when thereis no '{' before the statement from when thereisa '{' before it. (default 0).cino= cino=n2cino=n-2 if (cond) if (cond) if (cond) foo; foo; foo; else else else { { { bar; bar; bar; } } }cino-ffN Place the first opening brace ofa function or other block in column N. This applies only for an opening brace thatis not inside other braces andisat the start of the line. What comes after the braceisput relative to this brace. (default 0).cino= cino=f.5scino=f1s func() func() func() {{ { int foo; int foo; int foo;cino-{{N Place opening bracesN characters from the prevailing indent. This applies only for opening braces that are inside other braces. (default 0).cino= cino={.5scino={1s if (cond) if (cond) if (cond) {{ { foo; foo; foo;cino-}}N Place closing bracesN characters from the matching opening brace. (default 0).cino= cino={2,}-0.5scino=}2 if (cond) if (cond) if (cond) {{ { foo; foo; foo; } } }cino-^^N AddN to the prevailing indent insidea set of braces if the opening braceis in column 0. This can specifya different indent for whole ofa function (some may like to setit toa negative number). (default 0).cino= cino=^-2cino=^-s func() func() func() { { { if (cond)if (cond) if (cond) {{ { a = b; a = b; a = b; }} } } } }cino-LLN Controls placement of jump labels. IfNis negative, the label will be placedat column 1. IfNis non-negative, the indent of the label will be the prevailing indent minus N. (default -1).cino= cino=L2 cino=Ls func() func() func() { { { { { { stmt; stmt; stmt; LABEL: LABEL: LABEL: } } } } } }cino-::N Placecase labelsN characters from the indent of the switch(). (default'shiftwidth').cino= cino=:0 switch (x) switch(x) { { case 1: case 1: a = b; a = b; default: default: } }cino-==N Place statements occurring afteracase labelN characters from the indent of the label. (default'shiftwidth').cino= cino==10 case 11:case 11: a = a + 1; a = a + 1; b = b + 1;cino-llN IfN !=0 Vim will align withacase label instead of the statement afterit in the same line.cino= cino=l1 switch (a) { switch (a) {case 1: { case 1: { break; break;} }cino-bbN IfN !=0 Vim will aligna final "break" with thecase label, so that case..break looks likea sort of block. (default: 0). When using 1, consider adding "0=break" to'cinkeys'.cino= cino=b1 switch (x) switch(x) { { case 1: case 1: a = b; a = b; break; break; default: default: a = 0; a = 0; break; break; } }cino-ggN Place C++ scope declarationsN characters from the indent of the block they are in. (default'shiftwidth'). By default,a scope declarationis "public:", "protected:" or "private:". This can be adjusted with the'cinscopedecls' option.cino= cino=g0 { { public: public: a = b; a = b; private: private: } }cino-hhN Place statements occurring aftera C++ scope declarationN characters from the indent of the label. (default'shiftwidth').cino= cino=h10 public:public: a = a + 1; a = a + 1; b = b + 1;cino-NNN Indent inside C++ namespaceN characters extra compared toa normal block. (default 0).cino= cino=N-s namespace { namespace { void function(); void function(); } } namespace my namespace my { { void function(); void function(); } }cino-EEN Indent inside C++ linkage specifications (extern "C" or extern "C++")N characters extra compared toa normal block. (default 0).cino= cino=E-s extern "C" { extern "C" { void function(); void function(); } } extern "C" extern "C" { { void function(); void function(); } }cino-ppN Parameter declarations for K&R-style function declarations will be indentedN characters from the margin. (default'shiftwidth').cino= cino=p0cino=p2s func(a, b) func(a, b) func(a, b) int a; int a; int a; char b; char b; char b;cino-ttN Indenta function return type declarationN characters from the margin. (default'shiftwidth').cino= cino=t0cino=t7 int int int func() func() func()cino-iiN Indent C++ baseclass declarations andconstructor initializations, if they start ina new line (otherwise they are alignedat the right side of the ':'). (default'shiftwidth').cino= cino=i0 class MyClass : class MyClass : public BaseClass public BaseClass {} {} MyClass::MyClass() : MyClass::MyClass() : BaseClass(3) BaseClass(3) {} {}cino-++N Indenta continuation line (a line that spills onto the next) insidea functionN additional characters. (default'shiftwidth'). Outside ofa function, when the previous line ended ina backslash, the 2 *Nis used.cino= cino=+10 a = b + 9 * a = b + 9 * c; c;cino-ccN Indent comment lines after the comment opener, when thereis no other text with which to align,N characters from the comment opener. (default 3). See alsoformat-comments.cino= cino=c5 /* /* text. text. */ */cino-CCN WhenNis non-zero, indent comment lines by the amount specified with thec flag above even if thereis other text behind the comment opener. (default 0).cino=c0 cino=c0,C1 /******** /******** text. text. ********/ ********/ (Example uses ":set comments& comments-=s1:/* comments^=s0:/*")cino-//N Indent comment linesN characters extra. (default 0).cino= cino=/4 a = b; a = b; /* comment *//* comment */ c = d; c = d;cino-((N When in unclosed parentheses, indentN characters from the line with the unclosed parenthesis. Adda'shiftwidth' for every extra unclosed parentheses. WhenNis0 or the unclosed parenthesisis the first non-white character in its line, line up with the next non-white character after the unclosed parenthesis. (default'shiftwidth' * 2).cino= cino=(0 if (c1 && (c2 || if (c1 && (c2 || c3)) c3)) foo;foo; if (c1 && if (c1 && (c2 || c3))(c2 || c3)) { {cino-uuN Sameas (N, but for one nesting level deeper. (default'shiftwidth').cino= cino=u2 if (c123456789 if (c123456789 && (c22345 && (c22345 || c3)) || c3))cino-UUN WhenNis non-zero,do not ignore the indenting specified by( oru incase that the unclosed parenthesisis the first non-white character in its line. (default 0).cino= or cino=(s cino=(s,U1 c = c1 && c = c1 && (( c2 || c2 || c3 c3 ) && c4;) && c4;cino-wwN When in unclosed parentheses andNis non-zero and either using "(0" or "u0", respectively, or using "U0" and the unclosed parenthesisis the first non-white character in its line, line up with the character immediately after the unclosed parenthesis rather than the first non-white character. (default 0).cino=(0 cino=(0,w1 if ( c1 if ( c1 && ( c2&& ( c2|| c3)) || c3)) foo;foo;cino-WWN When in unclosed parentheses andNis non-zero and either using "(0" or "u0", respectively and the unclosed parenthesisis the last non-white character in its line anditis not the closing parenthesis, indent the following lineN characters relative to the outer context (i.e. start of the line or the next unclosed parenthesis). (default: 0).cino=(0 cino=(0,W4 a_long_line( a_long_line( argument,argument, argument);argument); a_short_line(argument, a_short_line(argument, argument); argument);cino-kkN When in unclosed parentheses which follow "if", "for" or "while" andNis non-zero, overrides the behaviour defined by "(N": causes the indent to beN characters relative to the outer context (i.e. the line where "if", "for" or "while" is). Has no effect on deeper levels of nesting. Affects flags like "wN" only for the "if", "for" and "while" conditions. If 0, defaults to behaviour defined by the "(N" flag. (default: 0).cino=(0 cino=(0,ks if (condition1 if (condition1 && condition2) && condition2) action();action(); function(argument1 function(argument1 && argument2); && argument2);cino-mmN WhenNis non-zero, line upa linestarting witha closing parenthesis with the first character of the line with the matching opening parenthesis. (default 0).cino=(s cino=(s,m1 c = c1 && ( c = c1 && ( c2 ||c2 || c3c3 ) && c4; ) && c4; if ( if ( c1 && c2c1 && c2 ) ) foo;foo;cino-MMN WhenNis non-zero, line upa linestarting witha closing parenthesis with the first character of the previous line. (default 0).cino= cino=M1 if (cond1 && if (cond1 && cond2 cond2 ) )java-cinoptionsjava-indentingcino-jjN Indent Java anonymous classes correctly. Also works well for Javascript. The value 'N'is currently unused butmust be non-zero (e.g. 'j1'). 'j1' will indent for example the following code snippet correctly:object.add(new ChangeListener() { public void stateChanged(ChangeEvent e) {do_something(); }});javascript-cinoptionsjavascript-indentingcino-JJN Indent JavaScriptobject declarations correctly by not confusing them with labels. The value 'N'is currently unused butmust be non-zero (e.g. 'J1'). If you enable this you probably also want to setcino-j.var bar = { foo: {that: this,some: ok, }, "bar":{a : 2,b: "123abc",x: 4,"y": 5 }}cino-))N Vim searches for unclosed parenthesesat mostN lines away. Thislimits the time needed to search for parentheses. (default 20 lines).cino-star*N Vim searches for unclosed commentsat mostN lines away. Thislimits the time needed to search for the start ofa comment. If your/* */ comments stop indenting afterN lines thisis the value you will want to change. (default 70 lines).cino-##N WhenNis non-zero recognize shell/Perl commentsstarting with '#',do not recognize preprocessor lines; allow right-shifting lines that start with "#". WhenNis zero (default): don't recognize '#' comments,do recognize preprocessor lines; right-shifting lines that start with "#" does not work.cino-PPN WhenNis non-zero recognizeC pragmas, and indent them like any other code; does not concern other preprocessor directives. WhenNis zero (default): don't recognizeC pragmas, treating them like every other preprocessor directive.The defaults, spelled out in full, are:cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,E0,ps,ts,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0,P0Vim putsa line in column 1 if:- It starts with '#' (preprocessor directives), if'cinkeys' contains '#0'.- It starts witha label (a keyword followed by ':', other than "case" and "default") and'cinoptions' does not contain an 'L' entry witha positive value.- Any combination of indentations causes the line to haveless than0 indentation.==============================================================================2. Indenting byexpressionindent-expressionThe basics for using flexible indenting are explained insection30.3 of theuser manual.If you want to write your own indent file,itmust set the'indentexpr'option. Setting the'indentkeys' optionis often useful.See the $VIMRUNTIME/indent/README.txt file for hints.See the $VIMRUNTIME/indent directory for examples.REMARKS ABOUT SPECIFIC INDENT FILESCLOJUREft-clojure-indentclojure-indentClojure indentation differs somewhat from traditional Lisps, due in part tothe use of square and curly brackets, and otherwise by community convention.These conventions are not universally followed, so the Clojure indentscriptoffersa few configuration options.(If the current Vim does not includesearchpairpos(), the indentscript fallsback to normal'lisp' indenting, and the followingoptions are ignored.)g:clojure_maxlinesSets maximum scan distance ofsearchpairpos(). Larger values tradeperformance for correctness when dealing with very long forms.A value of0 will scan without limits. The defaultis 300.g:clojure_fuzzy_indentg:clojure_fuzzy_indent_patternsg:clojure_fuzzy_indent_blacklistThe'lispwords' optionisalist of comma-separated words thatmark specialforms whose subforms should be indented with two spaces.For example:(defn bad [] "Incorrect indentation")(defn good [] "Correct indentation")If you would like to specify'lispwords' withapattern instead, you can usethe fuzzy indent feature:" Defaultlet g:clojure_fuzzy_indent = 1let g:clojure_fuzzy_indent_patterns = ['^with', '^def', '^let']let g:clojure_fuzzy_indent_blacklist =\ ['-fn$', '\v^with-%(meta|out-str|loading-context)$']g:clojure_fuzzy_indent_patterns andg:clojure_fuzzy_indent_blacklist arelists of patterns that will be matched against the unqualified symbolat thehead ofa list. This means thatapattern like"^foo" will match all thesecandidates:foobar,my.ns/foobar, and#'foobar.Each candidatewordis tested for special treatment in this order:1. Returntrue ifwordis literally in'lispwords'2. Returnfalse ifword matchesapattern ing:clojure_fuzzy_indent_blacklist3. Returntrue ifword matchesapattern ing:clojure_fuzzy_indent_patterns4. Returnfalse and indent normally otherwiseg:clojure_special_indent_wordsSome forms in Clojure are indented such that every subformis indented by onlytwo spaces, regardless of'lispwords'. If you havea custom construct thatshould be indented in this idiosyncratic fashion, you can add your symbols tothe defaultlist below." Defaultlet g:clojure_special_indent_words = \ 'deftype,defrecord,reify,proxy,extend-type,extend-protocol,letfn'g:clojure_align_multiline_stringsAlign subsequent lines in multi-line strings to the column after the openingquote, instead of the same column.For example:(def default "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")(def aligned "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")g:clojure_align_subformsBy default, parenthesized compound forms that look like function calls andwhose head subformis on its own line have subsequent subforms indented bytwo spaces relative to the opening paren:(foo bar baz)Setting this option to1 changes this behaviour so that all subforms arealigned to the same column, emulating the default behaviour ofclojure-mode.el:(foo bar baz)FORTRANft-fortran-indentBlock if, select case, select type, select rank, where, forall, type,interface, associate, block, enum, critical, and change team constructs areindented. The indenting of subroutines, functions, modules, and programblocksis optional. Comments, labeled statements, and continuation lines areindented in free source form, whereas they are not indented in fixed sourceform because of the left margin requirements. Hence manual indent correctionswill be necessary for labeled statements and continuation lines when fixedsource formis being used. For further discussion of themethod used for thedetection of source format seeft-fortran-syntax.Do loopsAlldo loops are left unindented by default. Do loops can be unstructured inFortran with (possibly multiple) loops ending ona labeled executablestatement of almost arbitrary type. Correct indentation requirescompiler-quality parsing. Old code withdo loops ending on labeled statementsof arbitrary type can be indented with elaborate programs suchas Tidy.Structured do/continue loops are also left unindented because continuestatements are used for purposes other than endingado loop. Programs suchas Tidy can convert structured do/continue loops to the do/enddo form. Doloops of the do/enddo variety can be indented. If you use only structuredloops of the do/enddo form, you should declare this by setting thefortran_do_enddo variable in your.vimrcas follows let fortran_do_enddo=1in whichcasedo loops will be indented. If all your loops are of do/enddotype only in, say, .f90 files, then you should seta buffer flag with anautocommand suchas au! BufRead,BufNewFile *.f90 let b:fortran_do_enddo=1to getdo loops indented in .f90 files and left alone in Fortran files withother extensions suchas .for.Program unitsIndenting of program units (subroutines, functions, modules, and programblocks) can be increased by setting the variable fortran_indent_more and canbe decreased by setting the variable fortran_indent_less. Thesevariablescan be set for all fortran files in your.vimrcas follows let fortran_indent_less=1A finer level ofcontrol can be achieved by setting the correspondingbuffer-local variableas follows let b:fortran_indent_less=1HTMLft-html-indenthtml-indenthtml-indentingThisis aboutvariables you can set in yourvimrc to customize HTML indenting.You can set the indent for the first line after<script> and<style>"blocktags" (default "zero"): :let g:html_indent_script1 = "inc" :let g:html_indent_style1 = "inc" VALUEMEANING "zero"zero indent "auto"auto indent (same indentas the blocktag) "inc"auto indent+ one indent stepYou can set the indent for attributes after an open <tag line: :let g:html_indent_attribute = 1 VALUEMEANING 1auto indent, one indent step more than <tag 2auto indent, two indent steps (default)> 2auto indent, more indent stepsManytags increase the indent for what follows per default (see "Add IndentTags" in the script). You can add furthertags with: :let g:html_indent_inctags = "html,body,head,tbody"You can also remove suchtags with: :let g:html_indent_autotags = "th,td,tr,tfoot,thead"Default valueis empty for both variables.Note: the initial "inctags" areonly defined once per Vim session.Uservariables are only read when thescriptis sourced. To enable yourchanges duringa session, without reloading the HTML file, you can manuallydo: :call HtmlIndent_CheckUserSettings()Detail: Calculation of indent inside "blocktags" with "alien" content: BLOCKTAG INDENT EXPR WHEN APPLICABLE<script>:{customizable} if first line of block: cindent(v:lnum) if attributes empty or contain "java": -1 else (vbscript, tcl, ...)<style>:{customizable} if first line of block: GetCSSIndent() else <!-- -->: -1IDRIS2ft-idris2-indentIdris 2 indentation can be configured with severalvariables thatcontrol theindentation level for different language constructs:The "g:idris2_indent_if" variable controls the indentation ofthen andelseblocks afterif statements. Defaults to 3.The "g:idris2_indent_case" variable controls the indentation of patterns incase expressions. Defaults to 5.The "g:idris2_indent_let" variable controls the indentation afterletbindings. Defaults to 4.The "g:idris2_indent_rewrite" variable controls the indentation afterrewriteexpressions. Defaults to 8.The "g:idris2_indent_where" variable controls the indentation ofwhereblocks. Defaults to 6.The "g:idris2_indent_do" variable controls the indentation indo blocks.Defaults to 3.Example configuration:let g:idris2_indent_if = 2let g:idris2_indent_case = 4let g:idris2_indent_let = 4let g:idris2_indent_rewrite = 8let g:idris2_indent_where = 6let g:idris2_indent_do = 3MATLABft-matlab-indentmatlab-indentmatlab-indentingThe setting Function indenting format in MATLAB Editor/Debugger LanguagePreferences corresponds to: :let g:MATLAB_function_indent = {0, 1 or 2 (default)}Where0is for Classic, 1 for Indent nestedfunctions and 2 for Indent allfunctions.PHPft-php-indentphp-indentphp-indentingNOTE:PHP files will be indented correctly only if PHPsyntaxis active.If you are editinga file inUnix'fileformat' and '\r' characters are presentbefore new lines, indentation won't proceed correctly; you have to removethose useless characters first witha command like: :%s /\r$//gOr, you can simply:let the variablePHP_removeCRwhenUnix to 1 and thescript will silently remove them when Vim loadsa PHP file (at eachBufRead).OPTIONS:PHP indenting can be altered in several ways by modifying the values of someglobal variables:php-commentPHP_autoformatcommentTo not enable auto-formatting of comments by default (if you want to use yourown'formatoptions'): :let g:PHP_autoformatcomment = 0Else, 't' will be removed from the'formatoptions'string and "qrowcb" will beadded, seefo-table for more information.-------------PHP_outdentSLCommentsTo add extra indentation to single-line comments: :let g:PHP_outdentSLComments = NWithN being the number of'shiftwidth' to add.Only single-line comments will be affected such as: # Comment // Comment /* Comment */-------------PHP_default_indentingTo add extra indentation to every PHP lines withN being the number of'shiftwidth' to add: :let g:PHP_default_indenting = NFor example, withN= 1, this will give: <?phpif (!isset($History_lst_sel)) if (!isset($History_lst_sel))if (!isset($History_lst_sel)) { $History_lst_sel=0;} else $foo="bar";$command_hist = TRUE; ?>(Notice the extra indentation between the PHP container markers and the code)-------------PHP_outdentphpescapeTo indent PHPescapetagsas the surrounding non-PHP code (only affects thePHPescape tags): :let g:PHP_outdentphpescape = 0-------------PHP_removeCRwhenUnixTo automatically remove '\r' characters when the'fileformat'is set to Unix: :let g:PHP_removeCRwhenUnix = 1-------------PHP_BracesAtCodeLevelTo indent bracesat the same level than the code they contain: :let g:PHP_BracesAtCodeLevel = 1This will give the following result: if ($foo){foo();}Instead of: if ($foo) {foo(); }NOTE:Indenting will bea bit slower if this optionis used because someoptimizations won't be available.-------------PHP_vintage_case_default_indentTo indent 'case:' and 'default:' statements in switch() blocks: :let g:PHP_vintage_case_default_indent = 1In PHP braces are not required inside 'case/default' blocks therefore 'case:'and 'default:' are indentedat the same level than the 'switch()' to avoidmeaningless indentation. You can use the above option to return to thetraditional way.-------------PHP_noArrowMatchingBy default the indentscript will indent multi-line chained calls by matchingthe position of the '->': $user_name_very_long->name() ->age() ->info();You can revert to the classic way of indenting by setting this option to 1: :let g:PHP_noArrowMatching = 1You will obtain the following result: $user_name_very_long->name() ->age() ->info();-------------PHP_IndentFunctionCallParametersExtra indentation levels to add to parameters in multi-line function calls. let g:PHP_IndentFunctionCallParameters = 1Function call arguments will indent 1 extra level. For two-space indentation: function call_the_thing( $with_this, $and_that ) { $this->do_the_thing( $with_this, $and_that ); }-------------PHP_IndentFunctionDeclarationParametersExtra indentation levels to add to arguments in multi-line functiondefinitions. let g:PHP_IndentFunctionDeclarationParameters = 1Function arguments in declarations will indent 1 extra level. For two-spaceindentation: function call_the_thing( $with_this, $and_that ) { $this->do_the_thing( $with_this, $and_that ); }PYTHONft-python-indentThe amount of indent can be set with theg:python_indentDictionary, whichneeds to be created before adding the items:let g:python_indent = {}The examples given are the defaults.Note that the dictionary values are setto an expression, so that you can change the value of'shiftwidth' laterwithout having to update these values.Indent after an open paren:let g:python_indent.open_paren = 'shiftwidth() * 2'Indent aftera nested paren:let g:python_indent.nested_paren = 'shiftwidth()'Indent fora continuation line:let g:python_indent.continue = 'shiftwidth() * 2'By default, the closing paren ona multiline construct lines up under thefirst non-whitespace character of the previous line.If you prefer that it's lined up under the first character of the line thatstarts the multiline construct, reset this key:let g:python_indent.closed_paren_align_last_line = v:falseThemethod usessearchpair() to look back for unclosed parentheses. Thiscan sometimes be slow, thusit timeouts after 150 msec. If you notice theindenting isn't correct, you can seta larger timeout in msec:let g:python_indent.searchpair_timeout = 500If looking back for unclosed parenthesisis still too slow, especially duringa copy-paste operation, or if you don't need indenting inside multi-lineparentheses, you can completely disable this feature:let g:python_indent.disable_parentheses_indenting = 1For backward compatibility, thesevariables are also supported:g:pyindent_open_pareng:pyindent_nested_pareng:pyindent_continueg:pyindent_searchpair_timeoutg:pyindent_disable_parentheses_indentingRft-r-indentFunction arguments are aligned if they span for multiple lines. If you preferdo not have the arguments offunctions aligned,put in yourvimrc: let r_indent_align_args = 0All lines beginning witha comment character, #, get the same indentationlevel of the normalR code. Users of Emacs/ESS may be used to have linesbeginning witha single# indented in the 40th column, ## indentedasR code,and ### not indented. If you prefer that lines beginning with commentcharacters are alignedas they are by Emacs/ESS,put in yourvimrc: let r_indent_ess_comments = 1If you prefer that lines beginning witha single# are alignedata columndifferent from the 40th one, you should seta new value to the variabler_indent_comment_column,as in the example below: let r_indent_comment_column = 30Any code aftera line that ends with "<-"is indented. Emacs/ESS does notindent the code ifitisa top-level function. If you prefera behavior likeEmacs/ESS one in this regard,put in yourvimrc: let r_indent_ess_compatible = 1Belowis an example of indentation with and without this option enabled: ### r_indent_ess_compatible = 1 ### r_indent_ess_compatible = 0 foo <- foo <- function(x) function(x) { { paste(x) paste(x) } }The code will be indented after lines that match thepattern'\(&\||\|+\|-\|\*\|/\|=\|\~\|%\|->\)\s*$'. If you want indentation afterlines that matcha different pattern, you should set the appropriate value ofr_indent_op_pattern in yourvimrc.SHELLft-sh-indentThe amount of indent applied undervarious circumstances ina shell file canbe configured by setting the following keys in theDictionaryb:sh_indent_defaults toa specific amount or toaFuncref that referencesafunction that will return the amount desired:b:sh_indent_options['default']Default amount of indent.b:sh_indent_options['continuation-line']Amount of indent to add toa continued line.b:sh_indent_options['case-labels']Amount of indent to add forcase labels.(not actually implemented)b:sh_indent_options['case-statements']Amount of indent to add forcase statements.b:sh_indent_options['case-breaks']Amount of indent to add (or more likelyremove) forcase breaks.VERILOGft-verilog-indentGeneral block statements suchas if, for, case, always, initial, function,specify and begin, etc., are indented. The module block statements (firstlevel blocks) are not indented by default. you can turn on the indent withsettinga variable in the.vimrcas follows: let b:verilog_indent_modules = 1then the module blocks will be indented. To stop this, remove the variable: :unlet b:verilog_indent_modulesTo set the variable only for Verilog file. The following statements can beused: au BufReadPost * if exists("b:current_syntax") au BufReadPost * if b:current_syntax == "verilog" au BufReadPost * let b:verilog_indent_modules = 1 au BufReadPost * endif au BufReadPost * endifFurthermore, setting the variable b:verilog_indent_width to change theindenting width (defaultis'shiftwidth'): let b:verilog_indent_width = 4 let b:verilog_indent_width = shiftwidth() * 2In addition, you can turn theverbose mode for debug issue: let b:verilog_indent_verbose = 1Make sure todo ":set cmdheight=2" first to allow the display of the message.VHDLft-vhdl-indentAlignment of generic/portmapping statements are performed by default. Thiscauses the following alignment example: ENTITY sync IS PORT ( clk : IN STD_LOGIC; reset_n : IN STD_LOGIC; data_input : IN STD_LOGIC; data_out : OUT STD_LOGIC ); END ENTITY sync;To turn this off, add let g:vhdl_indent_genportmap = 0to the.vimrc file, which causes the previous alignment example to change: ENTITY sync IS PORT ( clk : IN STD_LOGIC; reset_n : IN STD_LOGIC; data_input : IN STD_LOGIC; data_out : OUT STD_LOGIC ); END ENTITY sync;----------------------------------------Alignment of right-hand side assignment "<=" statements are performed bydefault. This causes the following alignment example: sig_out <= (bus_a(1) AND (sig_b OR sig_c)) OR (bus_a(0) AND sig_d);To turn this off, add let g:vhdl_indent_rhsassign = 0to the.vimrc file, which causes the previous alignment example to change: sig_out <= (bus_a(1) AND (sig_b OR sig_c)) OR (bus_a(0) AND sig_d);----------------------------------------Full-line comments (lines that begin with "--") are indented to be alignedwith the very previous line's comment, PROVIDED thatawhitespace followsafter "--".For example: sig_a <= sig_b; -- start of a comment -- continuation of the comment -- more of the same commentWhile inInsert mode, after typing "-- " (note thespace " "), hittingCTRL-Fwill align the current "-- " with the previous line's "--".If the very previous line does not contain "--", THEN the full-line commentwill be aligned with the start of the next non-blank line thatis NOTafull-line comment.Indenting the following code: sig_c <= sig_d; -- comment 0 -- comment 1 -- comment 2 --debug_code: --PROCESS(debug_in) --BEGIN -- FOR i IN 15 DOWNTO 0 LOOP -- debug_out(8*i+7 DOWNTO 8*i) <= debug_in(15-i); -- END LOOP; --END PROCESS debug_code; -- comment 3 sig_e <= sig_f; -- comment 4 -- comment 5results in: sig_c <= sig_d; -- comment 0 -- comment 1 -- comment 2 --debug_code: --PROCESS(debug_in) --BEGIN -- FOR i IN 15 DOWNTO 0 LOOP -- debug_out(8*i+7 DOWNTO 8*i) <= debug_in(15-i); -- END LOOP; --END PROCESS debug_code; -- comment 3 sig_e <= sig_f; -- comment 4 -- comment 5Notice that "--debug_code:" does not align with "-- comment 2"because thereis nowhitespace that follows after "--" in "--debug_code:".Given the dynamic nature of indenting comments, indenting should be doneTWICE. On the first pass, code will be indented. On the second pass,full-line comments will be indented according to the correctly indented code.VIMft-vim-indentg:vim_indentVim scripts indentation can be configured with theg:vim_indent dictionaryvariable. It supports 3 keys,line_continuation,more_in_bracket_block,andsearchpair_timeout.line_continuation expectsa number which will be added to the indent level ofa continuation linestarting witha backslash, and defaults to`shiftwidth() * 3`. It also acceptsa string, whichis evaluatedat runtime.more_in_bracket_block expectsaboolean value; when on, an extrashiftwidth()is added inside blocks surrounded with brackets. It defaults tov:false.searchpair_timeout expectsa number which will be passed tosearchpair()asa timeout. Increasing the value might give more accurate results, but alsocauses the indentation to take more time. It defaults to 100 (milliseconds).Example of configuration:let g:vim_indent = #{ \ line_continuation: shiftwidth() * 3, \ more_in_bracket_block: v:false, \ searchpair_timeout: 100, \ }g:vim_indent_contThis variableis equivalent tog:vim_indent.line_continuation.It's supported for backward compatibility.YAMLft-yaml-indentBy default, the yaml indentscript does not try to detect multiline scalars.If you want to enable this, set the following variable: let g:yaml_indent_multiline_scalar = 1 vim:tw=78:ts=8:noet:ft=help:norl: