Thursday, December 29, 2016

Re: Opening new line above or below Perl comment line

On 2016-12-29, $Bill wrote:
> When typing a Perl comment, I have no problem with vim starting the next line
> with a '#' for me when the line wraps in insert mode, but in command mode
> when I type 'o' OR 'O' to start a new line, I don't want the new line to
> be a comment line just because the line above or below was a comment and
> I'd like vim to assume the new line is code and do normal Perl indenting.
>
> Please help me with an option change or some syntax or indent file change
> or whatever that will stop assuming a new comment on o/O commands.

The reason for this is that some filetype plugins, including
ftplugin/perl.vim, add the 'o' flag to 'formatoptions'. To fix that
for all filetype plugins, I have this in my ~/.vimrc:

au FileType * setlocal formatoptions-=o

I'm not positive, but I think that that line has to come _after_
":filetype plugin on" so that that :setlocal command will be
executed after any commands in a filetype plugin.

You can fix the problem for just Perl by replacing the * above with
the name perl, or you can create a file named (assuming Unix)
~/.vim/after/ftplugin/perl.vim containing the line:

setlocal formatoptions-=o

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.
For more options, visit https://groups.google.com/d/optout.

No comments: