5

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 A<Space>#<...


4

Vimscript does have comments and they're started by the " character. They always work at the beginning of the line: " echo usage echo "hello" 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. [...] ...


2

set fo-=r fo -=o *'formatoptions'* *'fo'* '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). ...


2

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 Where ...


2

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


2

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) :let ...


1

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. if exists("colors_name") exe "colors " . colors_name else runtime! syntax/syncolor.vim endif where syntax/syncolor.vim ...


1

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 MIT License Copyright (c) 2016 David Ben Knoble Permission is hereby ...


1

Try nmap <leader>cv <leader>ca<leader>cc<leader>ca Note that you can't use nore-stuff here.


1

set fo+=j :h fo-table: ... j Where it makes sense, remove a comment leader when joining lines. For example, joining: int i; // the index ~ // in the list ~ Becomes: int i; // the index in the list ~ ... default formatoptions in vim8 : tcq default formatoptions in neovim : tcqj


1

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


1

This is an extension on work in: https://vi.stackexchange.com/a/8130/26305 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 ...


Only top voted, non community-wiki answers of a minimum length are eligible