Reset comments only when a file is opened in Vim

When I look at long code files with detailed comments in Vim, I would like to be able to upload files with folded comments, but everything else expands. The current bend configuration in mine is .vimrc:

set foldmethod=syntax
set nofoldenable

That way, when I want to start folding, I can just start executing the commands z. But is there only a way to reset (block) comments?

+5
source share
1 answer

You can execute a global command to close all folds of block comments:

:g/^\/\*/foldc

:help foldclose , /* ( ). , / * . /, (, :g#^/\*#foldc). , , . :

set fdm=syntax fen
augroup closeCommentFolds
   au!
   au FileType javascript %foldo | g/^\/\*/foldc
   au FileType ruby %foldo | g/^=begin/foldc
augroup end

, ^ regex , /* =begin . , ^\s* ^. %foldo , foldenable, ( ).

+6

All Articles