Vi and Vim Asked on January 1, 2021
I’m using the accepted answer in this post, and as such, tried using the character *
in my .vimrc
, but it seems to generate E20: Mark not set
as error, which i want to ignore (only for the instance when the *
is used).
I’m aware of the silent!
command, which ignore errors on a specific command, but i believe this might not work in this case.
Any way to do this?
You can't just start lines with *
in your vimrc and have Vim ignore them. *
is not really a comment character, it's a valid command.
Under 'nocompatible'
(which is most surely the mode under which everyone is using Vim these days), :*
is a shortcut to :'<,'>
, which is the range of lines comprising the last Visual selection. (See :help cpo-*
, keeping in mind that under 'nocompatible'
this option is not set.)
Instead of trying to get Vim to accept your special syntax, just adapt it so that it will work inside comments (actual Vimscript comments.)
You can do that by changing your matching pattern to:
'v^s*("s*)?zs*+'
This will accept an optional "
(plus whitespace) before the stars.
In that case, you would write:
" * first header
(Some Vimscript here.)
" ** second header
(More text.)
" *** third header
(Test.)
But then, consider whether this is actually that much of an enhancement over the default foldmethod=marker
settings, under which you would write the following to accomplish the same folding configuration:
" first header {{{1
(Some Vimscript here.)
" second header {{{2
(More text.)
" third header {{{3
(Test.)
Correct answer by filbranden on January 1, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP