How to disable automatically comment the next line in a cpp file?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to disable automatically comment the next line in a cpp file?

Peng Yu
Hi,

Suppose that I am pasting some c++ code in vim (with some comment
starting with //). The lines after the comments are also automatically
commented, which is very annoy. Is there a way to disable this?

Regards,
Peng

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to disable automatically comment the next line in a cpp file?

Gary Johnson-4
On 2011-09-09, Peng Yu wrote:
> Hi,
>
> Suppose that I am pasting some c++ code in vim (with some comment
> starting with //). The lines after the comments are also automatically
> commented, which is very annoy. Is there a way to disable this?

There are a number of ways to disable this, but I think a better
approach would be to fix the problem with pasting.  There are
essentially two ways to paste in Vim:  inserting the characters as
if you typed them and inserting the text as it was formatted when
copied.  You seem to be doing the former when you want to be doing
the latter.

How exactly are you pasting this C++ code?  Are you using gvim or
vim in a terminal?  Windows or Unix?

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
Reply | Threaded
Open this post in threaded view
|

Re: How to disable automatically comment the next line in a cpp file?

Taylor Hedberg
In reply to this post by Peng Yu
Try:

    :set formatoptions-=ro

See `:help fo-table` for details.

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to disable automatically comment the next line in a cpp file?

Peng Yu
In reply to this post by Gary Johnson-4


On Sep 9, 11:16 pm, Gary Johnson <[hidden email]> wrote:

> On 2011-09-09, Peng Yu wrote:
>
> > Hi,
>
> > Suppose that I am pasting some c++ code in vim (with some comment
> > starting with //). The lines after the comments are also automatically
> > commented, which is very annoy. Is there a way to disable this?
>
> There are a number of ways to disable this, but I think a better
> approach would be to fix the problem with pasting.  There are
> essentially two ways to paste in Vim:  inserting the characters as
> if you typed them and inserting the text as it was formatted when
> copied.  You seem to be doing the former when you want to be doing
> the latter.
>
> How exactly are you pasting this C++ code?  Are you using gvim or
> vim in a terminal?  Windows or Unix?

I use Commmand+C on Mac to paste (in GUI version). Is it helpful in
determining what the solution is?

Thanks,
Peng

--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to disable automatically comment the next line in a cpp file?

Gary Johnson-4
On 2011-09-09, Peng Yu wrote:

> On Sep 9, 11:16 pm, Gary Johnson <[hidden email]> wrote:
> > On 2011-09-09, Peng Yu wrote:
> >
> > > Hi,
> >
> > > Suppose that I am pasting some c++ code in vim (with some comment
> > > starting with //). The lines after the comments are also automatically
> > > commented, which is very annoy. Is there a way to disable this?
> >
> > There are a number of ways to disable this, but I think a better
> > approach would be to fix the problem with pasting.  There are
> > essentially two ways to paste in Vim:  inserting the characters as
> > if you typed them and inserting the text as it was formatted when
> > copied.  You seem to be doing the former when you want to be doing
> > the latter.
> >
> > How exactly are you pasting this C++ code?  Are you using gvim or
> > vim in a terminal?  Windows or Unix?
>
> I use Commmand+C on Mac to paste (in GUI version). Is it helpful in
> determining what the solution is?

Unfortunately, I know little about Macs.  If Vim sees the Command+C
and executes some paste operation, then the problem can probably be
fixed in Vim so that pasting "just works".  If, on the other hand,
Command+C is seen only by the Mac OS and all Vim sees is the text
characters in its input stream, then you may have to resort to some
other, less attractive solution, such as changing your
'formatoptions' as Taylor suggested, or toggling the 'paste' option
before and after the pasting operation.  Toggling 'paste' involves
extra keystrokes, but is a reliable solution.  See

    :help 'paste'

One way to determine whether Vim sees the Command+C would be to
enter insert mode, type CTRL-V, then type Command+C and see what
appears.  If it's the contents of the Mac's copy-paste buffer, then
Vim doesn't see that key combination and you may be stuck with
toggling 'paste'.

Bear in mind, though, that I don't know Macs well enough to be
giving reliable advice.

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
Reply | Threaded
Open this post in threaded view
|

Re: How to disable automatically comment the next line in a cpp file?

jreidthompson-2
In reply to this post by Peng Yu
On 9/10/2011 12:02 AM, Peng Yu wrote:
> Hi,
>
> Suppose that I am pasting some c++ code in vim (with some comment
> starting with //). The lines after the comments are also automatically
> commented, which is very annoy. Is there a way to disable this?
>
> Regards,
> Peng
>
before pasting, do

:set paste


--
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
Reply | Threaded
Open this post in threaded view
|

Re: How to disable automatically comment the next line in a cpp file?

Gerardo Marset
In reply to this post by Gary Johnson-4
El 10/09/11 02:57, Gary Johnson escribió:
> If, on the other hand, Command+C is seen only by the Mac OS and all
> Vim sees is the text characters in its input stream, then you may have
> to resort to some other, less attractive solution, such as changing
> your 'formatoptions' as Taylor suggested, or toggling the 'paste'
> option before and after the pasting operation.
If that is the case, another possible solution would be using a Vim
command to paste instead. Try "+p and "*p.
Also, see :h 'clipboard'.

--
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