Wednesday, December 7, 2022

Re: automatic C // comments


Perfect!  Thanks!!
On Wednesday, December 7, 2022 at 3:20:12 PM UTC-5 Gary Johnson wrote:
On 2022-12-07, rwmit...@gmail.com wrote:
> Reading runtime/changes.doc, I see using <Ctrl>U immediately after an indented
> comment line is created, undoes the auto comment and puts the cursor in the
> correct column for the next line. This is likely the correct solution for me.
>
> This is the relevant lines from the above document:
>
> *fo-r*
> r Automatically insert the current comment leader after hitting
> <Enter> in Insert mode.
> *fo-o*
> o Automatically insert the current comment leader after hitting 'o' or
> 'O' in Normal mode. In case comment is unwanted in a specific place
> use CTRL-U to quickly delete it. |i_CTRL-U|
> *fo-/*
> / When 'o' is included: do not insert the comment leader for a //
> comment after a statement, only when // is at the start of the line.
>
> The last 3 lines looks like exactly what I was initially asking for, but I
> don't understand how to make that happen.

The ex command to make that happen is

set fo+=/

That will add the option "letter" / to 'formatoptions'. See

:help set+=

You can put that command in your vimrc to have it apply to all
comments or in a file named ~/.vim/after/ftplugin/c.vim to have it
apply only to C files. See

:help after-directory
:help ftplugin-overrule
:help ftplugin

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/8007d036-c378-4c1e-b1d4-3338e2e520b4n%40googlegroups.com.

No comments:

Post a Comment