Vim Tips Wiki
(→‎Comments: request complete, instead of abbreviated, commands)
(→‎Comments: reply)
Line 80: Line 80:
 
----
 
----
 
I'm having trouble understanding this tip since I'm rather inexperienced. Is <code>au</code> short for <code>autocmd</code>? Is anything else in this tip shorthand for something longer? If you could please update the tip to have complete terms, I think that would help immensely. --[[User:Josephholsten|Josephholsten]] 10:02, 18 May 2009 (UTC)
 
I'm having trouble understanding this tip since I'm rather inexperienced. Is <code>au</code> short for <code>autocmd</code>? Is anything else in this tip shorthand for something longer? If you could please update the tip to have complete terms, I think that would help immensely. --[[User:Josephholsten|Josephholsten]] 10:02, 18 May 2009 (UTC)
  +
:Yes, <tt>au</tt> is <tt>autocmd</tt>. One way to check is to guess that the command is an Ex command (has a preceding colon) because it is intended for the [[vimrc]] file. Then in Vim, type <tt>:h :au</tt> and press Tab or Ctrl-d or just Enter. Command <tt>setl</tt> is <tt>setlocal</tt>, and some more abbreviations are used (for something after ''set'', use <tt>:h 'fo</tt> then press Tab or Ctrl-d or just Enter, because it's an option).
  +
:We try to remove abbreviations from tips, and I try to make sure that new tips use in-full terms. However, sometimes the abbreviation (like <tt>au</tt>) is hard to avoid, although it's silly for this tip to not mention that it is doing ("set an autocommand..."). [[User:JohnBeckett|JohnBeckett]] 12:06, 18 May 2009 (UTC)

Revision as of 12:06, 18 May 2009

Tip 1361 Printable Monobook Previous Next

created October 18, 2006 · complexity basic · author Johnny · version 5.7


Auto-comment is a good idea for Vim, but sometimes you may like to disable it. To disable for all files:

au FileType * setl fo-=cro

comment character will not auto repeat in the next line. The key for this is the "f" flag.

 TO DO 

  • The above line looks like it needs to be fixed (very briefly state what is achieved; "auto repeat" is probably not very helpful to someone who doesn't know what this tip does).
  • Is the "The key..." sentence relevant?

References

Other ways

Define an auto command which gets executed whenever a C/C++ file is opened. Put the following line in your vimrc:

au FileType c,cpp setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,f://

Or use:

setlocal comments-=://
setlocal comments+-f://

This has been annoying me for a while as well:

:set fo=cql

That takes the ro out of the formatoptions.

a :set fo-=ro (could work, I didn't get it working though)


I saw The following block in the c.vim, right next to the lines mentioned in the original comment. commenting off this one worked perfectly fine.

" Set 'formatoptions' to break comment lines but not other lines,
" and insert the comment leader when hitting <CR> or using "o".
setlocal fo-=t fo+=croql

changed to

" Set 'formatoptions' to break comment lines but not other lines,
" and insert the comment leader when hitting <CR> or using "o".
" setlocal fo-=t fo+=croql

Comments

 TO DO 

  • Remove following comments after attending to issues.

Hi Nminus! Thanks for clearing up the tip. I haven't got time to digest what this is about at the moment, but I wanted to note a couple of issues. The {{Todo}} will remind me to clean this out if you don't (it would be great if you notice this, attend to the issues, then delete all my comments -- then I won't have to). --JohnBeckett 11:21, 7 August 2008 (UTC)

  • See the first Todo near the top. Was some text from the old tip accidentally left after your edit?
  • Our style is to make headings like "Other ways" rather than "Other Ways".
  • We keep a ==Comments== section in each tip to encourage relevant comments here (even if there is nothing after "Comments"). Such comments are temporary only (and will be removed when any issues are fixed).
  • By changing "Comments" to "Other ways" you are effectively moving the comments into the tip. Are you sure they are ready for that? We have the convention that stuff under "Comments" might be someone's confused opinion, whereas earlier text should be good information. If you think a comment is not helpful, just delete it. I have not investigated the issue in this tip, so I don't want to form an opinion, but my gut feeling is that any comments suggesting that editing c.vim is a good idea should be removed.

I'm having trouble understanding this tip since I'm rather inexperienced. Is au short for autocmd? Is anything else in this tip shorthand for something longer? If you could please update the tip to have complete terms, I think that would help immensely. --Josephholsten 10:02, 18 May 2009 (UTC)

Yes, au is autocmd. One way to check is to guess that the command is an Ex command (has a preceding colon) because it is intended for the vimrc file. Then in Vim, type :h :au and press Tab or Ctrl-d or just Enter. Command setl is setlocal, and some more abbreviations are used (for something after set, use :h 'fo then press Tab or Ctrl-d or just Enter, because it's an option).
We try to remove abbreviations from tips, and I try to make sure that new tips use in-full terms. However, sometimes the abbreviation (like au) is hard to avoid, although it's silly for this tip to not mention that it is doing ("set an autocommand..."). JohnBeckett 12:06, 18 May 2009 (UTC)