- Supports Vim and Neovim.
- Supports legacy Vim script syntax and Vim9 script syntax if possible.
- Uses
g:vim_indent_cont
when indenting of continues line.
This is an example of installation using vim-plug.
Plug 'rbtnn/vim-vimscript_indentexpr'
Following examples are before/after when using gg=G
.
shiftwidth()
is 4
and g:vim_indent_cont
is 2
in following examples.
-
Augroup (Legacy)
before
augroup xxx autocmd! autocmd FileType vim \ : if 1 \ | echo 1234 \ | else \ | echo 5678 \ | endif augroup END
after
augroup xxx autocmd! autocmd FileType vim \ : if 1 \ | echo 1234 \ | else \ | echo 5678 \ | endif augroup END
-
Heredoc (Legacy, not support Neovim)
before
if v:true var lines =<< trim END text text text text text text text text text text text text text text text text text END echo 123 else echo 456 endif
after
if v:true var lines =<< trim END text text text text text text text text text text text text text text text text text END echo 123 else echo 456 endif
-
Binary operators (Vim9)
before
if v:true let a = p ? 1 : 2 echo 234 :2 echo 234 endif
after
if v:true let a = p ? 1 : 2 echo 234 :2 echo 234 endif
-
Continues method (Vim9)
before
x ->method() ->method() ->method() ->method() F()
after
x ->method() ->method() ->method() ->method() F()
-
Def (Vim9)
before
def outter() echo 12 def inner() echo 34 enddef enddef
after
def outter() echo 12 def inner() echo 34 enddef enddef
-
Continues parenthesis (Vim9) {not implemented yet}
before
Func ( arg ) echo 123
after
Func ( arg ) echo 123
-
Continues expr (Vim9)
before
var total = m + n echo 123
after
var total = m + n echo 123
-
Block (Vim9)
before
{ let n = a + b return n }
after
{ let n = a + b return n }
-
Block (Vim9) {not implemented yet}
before
var Lambda = (arg) => { let n = a + b return n } echo 123
after
var Lambda = (arg) => { let n = a + b return n } echo 123
NOTE: This recognizes Block but Lambda and Block.
-
Lambda and Block (Vim9) {not implemented yet}
before
var Lambda = (arg) => { let n = a + b return n } echo 123
after
var Lambda = (arg) => { let n = a + b return n } echo 123
-
Dictionary (Vim9) {not implemented yet}
before
if v:true popup_setoptions(winid, { "title": "xyz", }) else popup_setoptions(winid, { "title": "abc", }) endif
after
if v:true popup_setoptions(winid, { "title": "xyz", }) else popup_setoptions(winid, { "title": "abc", }) endif