3

I have a long Lua (LuaDoc) comment which I want to convert to a multi-line comment using the VIM command 'qgap'. Guess there is some solution in .vimrc with format-comments, but I couldn't figure it out myself.

Example:

--- This is a very long LuaDoc comment line which I want to break into many lines

shall become:

--- This is a very long Lua doc  
-- comment line which I want to  
-- break into many lines  
nobody
  • 19,814
  • 17
  • 56
  • 77
Erwin411
  • 734
  • 1
  • 7
  • 14
  • 4
    One possible solution would be `:set comments=s1:---,m:--,ex:--`, but it seems a bit redundant. And how can I add it to .vimrc to be active for .lua files only? – Erwin411 Sep 14 '12 at 11:21
  • 4
    With an `autocmd FileType lua set comments=s1:---,m:--,ex:--` in `~/.vimrc` or with `set comments=s1:---,m:--,ex:--` in `~/.vim/after/ftplugin/lua.vim`. – romainl Sep 14 '12 at 11:54
  • Thanks, this helps. But I still think that my comments string is a bit rudimentary. For example, it formats the whole comment block and not just a paragraph within that block. – Erwin411 Sep 14 '12 at 12:11
  • 1
    @Erwin411 That has nothing to do with your comments string, that has to do with what [Vim considers to be a paragraph](http://vimdoc.sourceforge.net/htmldoc/motion.html#paragraph). If you want it to format something less than the entire comment block, using some other way of designation the target for `gq` (motion command, visual selection, etc.) – Mud Sep 14 '12 at 19:33

0 Answers0