How to add two lines in vim?

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

How to add two lines in vim?

Peng Yu
Hi,

O can only add one lines. I'm wondering if there is a built in command to add two lines at a time in vim. Does anybody know?

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 add two lines in vim?

Chris Schneider
No built in that I know of.  O<enter> is a very quick way. and if you find yourself doing it a lot, go ahead and map it to something you remember. nmap <leader>o o<cr> for instance.


On Sun, Jan 20, 2013 at 3:52 PM, Peng Yu <[hidden email]> wrote:
Hi,

O can only add one lines. I'm wondering if there is a built in command to add two lines at a time in vim. Does anybody know?

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

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

Re: How to add two lines in vim?

Bee
In reply to this post by Peng Yu


On Jan 20, 2:52 pm, Peng Yu <[hidden email]> wrote:
> Hi,
>
> O can only add one lines. I'm wondering if there is a built in command to add two lines at a time in vim. Does anybody know?
>
> Thanks,
> Peng

If you do 2O<return><esc> you will have two lines
--OR--
try 22O<return><esc> and you will have 22 new lines

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

Re: How to add two lines in vim?

Chris Schneider
That's what I get for not checking help before replying :)  Didn't realize that took a count.


On Sun, Jan 20, 2013 at 4:13 PM, Bee <[hidden email]> wrote:


On Jan 20, 2:52 pm, Peng Yu <[hidden email]> wrote:
> Hi,
>
> O can only add one lines. I'm wondering if there is a built in command to add two lines at a time in vim. Does anybody know?
>
> Thanks,
> Peng

If you do 2O<return><esc> you will have two lines
--OR--
try 22O<return><esc> and you will have 22 new lines

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

Re: How to add two lines in vim?

Bee
In reply to this post by Bee


On Jan 20, 3:13 pm, Bee <[hidden email]> wrote:

> On Jan 20, 2:52 pm, Peng Yu <[hidden email]> wrote:
>
> > Hi,
>
> > O can only add one lines. I'm wondering if there is a built in command to add two lines at a time in vim. Does anybody know?
>
> > Thanks,
> > Peng
>
> If you do 2O<return><esc> you will have two lines
> --OR--
> try 22O<return><esc> and you will have 22 new lines
>
> Bill

Correction:

2O<esc>i
--OR--
22O<esc>i

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

Re: How to add two lines in vim?

Bee
In reply to this post by Chris Schneider
On Jan 20, 3:16 pm, Chris Schneider <[hidden email]>
wrote:
> That's what I get for not checking help before replying :)  Didn't realize
> that took a count.

It is a little strange that it does not populate the file with the
blank lines until <esc> is pressed. Mac terminal vim version 7.3.762

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

Re: How to add two lines in vim?

Chris Schneider
I don't see that behavior in macvim. I get new lines that are there right away.


On Sun, Jan 20, 2013 at 4:22 PM, Bee <[hidden email]> wrote:
On Jan 20, 3:16 pm, Chris Schneider <[hidden email]>
wrote:
> That's what I get for not checking help before replying :)  Didn't realize
> that took a count.

It is a little strange that it does not populate the file with the
blank lines until <esc> is pressed. Mac terminal vim version 7.3.762

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 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 add two lines in vim?

Marvin Renich
In reply to this post by Bee
* Bee <[hidden email]> [130120 18:24]:

>
>
> On Jan 20, 3:13 pm, Bee <[hidden email]> wrote:
> > On Jan 20, 2:52 pm, Peng Yu <[hidden email]> wrote:
> >
> > > Hi,
> >
> > > O can only add one lines. I'm wondering if there is a built in command to add two lines at a time in vim. Does anybody know?
> >
> > > Thanks,
> > > Peng
> >
> > If you do 2O<return><esc> you will have two lines
> > --OR--
> > try 22O<return><esc> and you will have 22 new lines
> >
> > Bill
>
> Correction:
>
> 2O<esc>i
> --OR--
> 22O<esc>i

Actually, the trailing i is only needed if you want to end up in insert
mode, and is not part of the command that inserts multiple lines.

Note that any text inserted as part of the O or o command gets inserted
multiple times, as well.  So that 5OHello<esc> will insert the line
«Hello» five times.

The delay between the <esc> and inserting the repetitions of the text
only occurs in terminal vim, not gvim or macvim.  It is a consequence of
the keyboard handling.  Terminal vim must wait a little bit to see if
the <esc> is part of a terminal escape sequence for keys like the arrow
keys or function keys.

HTH...Marvin

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