Well, "put text into a box" is a well-known Vim excercise. I'm not sure where I saw it for the first time, but the most elegant solution, IMO, is to use :h v_r
So it becomes:
nnoremap <leader># I#<Space><Esc>A<Space>#<Esc>yy2P<C-V>$r#2j.
I#<Space><Esc> --- add "# " at the start of line
Vimscript does have comments and they're started by the " character.
They always work at the beginning of the line:
" echo usage
They sometimes work inline, but not always. It depends on the command.
See :help :comment, which says:
" after a command causes the rest of the line to be ignored. This can be used
to add comments. [...]
set fo-=r fo -=o
'formatoptions' 'fo' string (default: "tcqj", Vi default: "vt")
local to buffer
This is a sequence of letters which describes how automatic
formatting is to be done. See |fo-table|. When the 'paste' option is
on, no formatting is done (like 'formatoptions' is empty). ...
You could use a combination of :execute and substitute. The idea would be to use substitute to replace the %s in the commentstring by your TODO and then use execute to forge the content of the mapping.
Your js mapping could be something like this:
nnoremap td :execute "norm! A " . substitute(&commentstring, '%s', 'TODO ', '')<CR>A
It is a bad habit to do spaces and remarks in the same line of the mapping. I believe it includes them in the mapping and it causes the beep(about the remark I am not sure). So try to remove them and see what happens.
I have asked a similar question Beep upon using a mapping .
As a temporary solution:
set visualbell t_vb=
Disables all beeps
Just looking at :h matchit should reveal the answer. I see variable b:match_skip is relevant.
Per the docs the default value of this would be set with:
:let b:match_skip = 's:comment\|string'
With that setting % ignores brackets within or partially within comments, for instance.
Setting it to something that evaluates to 0 (i.e. nothing is skipped)
I can confirm this with the latest vim-nightly.
your vimrc loads first (where you have defined your highlighing)
then syntax/synload.vim does override it with:
" Set the default highlighting colors. Use a color scheme if specified.
exe "colors " . colors_name
where syntax/syncolor.vim ...
Ok, so I have a prototype of a license concealer (not fold) written, but I think because of the way conceal and cchar work, I can't get the lines to collapse into one. For that, folding may be better.
A quick example, that doesn't work with comments (yet):
let text =<< trim END
Copyright (c) 2016 David Ben Knoble
Permission is hereby ...
j Where it makes sense, remove a comment leader when joining lines. For
int i; // the index ~
// in the list ~
int i; // the index in the list ~
default formatoptions in vim8 : tcq
default formatoptions in neovim : tcqj
My answer is very similar to Martin Tournoij (full credit to him).
This just makes it in a single-line command. When you run this, it will disable continuation of comment permanently:
echo 'au FileType * set fo-=c fo-=r fo-=o' >> ~/.vimrc
This is an extension on work in:
Uses replace to handle existing comments not in specific indentation, instead of vim key commands and allows a dictionary of filetypes which can be easily toggled with 'set filetype=X'
Paste the following, declare your missing filetype in dictionary (default comment char is '#') and ...