Opening new line above or below Perl comment line

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Opening new line above or below Perl comment line

$Bill
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.

TIA, Bill

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Opening new line above or below Perl comment line

Gary Johnson-4
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Opening new line above or below Perl comment line

$Bill
In reply to this post by $Bill
On Thursday, December 29, 2016 at 4:47:11 PM UTC-8, $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.
>
> TIA, Bill
Nevermind, after some more searching, I found the answer in another thread.

I took the 'o' out of formatoptions by adding a :set formatoptions in my rc file.


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