I want to put line in my .vimrc
file so that it will fold the /* ... */
like comments on autostart with *.java
files.
So far I have came up with this but it does not want to work (although the command works in vim)
autocmd BufReadPre,BufReadPost,FileReadPre,FileReadPost *.java execute ":normal :%g/\/\*/normal! zf%"
:global
command already is an Ex command; there's no need for :normal
(which is for stuff like j
, zf
, /
). This should work::autocmd BufReadPre,BufReadPost,FileReadPre,FileReadPost *.java %g/\/\*/normal! zf%
FileType
event::autocmd FileType java %g/\/\*/normal! zf%
syntax/c.vim
); you enable it via:setlocal foldmethod=syntax
If you really need custom folding, :help fold-expr
is the way to go.