[vim] Edit the command line

This is a discussion on [vim] Edit the command line within the Editors forums in Theory and Concepts category; When you type ESC : and then then UP Arrow to get a previous command, how can you edit that command, e.g. I want to change the beginning of the command, so I might try ESC :0 (beginning of line in VIM), but the ESC takes you out of the given command. CMM...

Go Back   Application Development Forum > Theory and Concepts > Editors

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-04-2008, 10:29 AM
Charles M
Guest
 
Default [vim] Edit the command line

When you type

ESC :

and then then UP Arrow to get a previous command, how can
you edit that command, e.g. I want to change the beginning
of the command, so I might try ESC :0 (beginning of line in VIM),
but the ESC takes you out of the given command.


CMM
Reply With Quote
  #2  
Old 09-04-2008, 10:50 AM
Tuomas Kasmra
Guest
 
Default Re: [vim] Edit the command line

2008-09-04, Charles M skribis:
> When you type
>
> ESC :
>
> and then then UP Arrow to get a previous command, how can
> you edit that command, e.g. I want to change the beginning
> of the command, so I might try ESC :0 (beginning of line in VIM),
> but the ESC takes you out of the given command.
>
>
> CMM


Just use arrow keys or <home> key to move. There should be no need to
press <esc> again at the command line.

--
kasmra
:wq
Reply With Quote
  #3  
Old 09-04-2008, 11:35 AM
Kenny McCormack
Guest
 
Default Re: [vim] Edit the command line

In article <slrngbvtfa.3mt.kasmra@foresto.suomi.net>,
Tuomas Kasmra <kasmra@ne-spamon.gmail.com> wrote:
>2008-09-04, Charles M skribis:
>> When you type
>>
>> ESC :
>>
>> and then then UP Arrow to get a previous command, how can
>> you edit that command, e.g. I want to change the beginning
>> of the command, so I might try ESC :0 (beginning of line in VIM),
>> but the ESC takes you out of the given command.
>>
>>
>> CMM

>
>Just use arrow keys or <home> key to move. There should be no need to
>press <esc> again at the command line.


Or use q:
(instead of ESC

Reply With Quote
  #4  
Old 09-04-2008, 11:53 AM
Charles M
Guest
 
Default Re: [vim] Edit the command line

On 2008-09-04, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <slrngbvtfa.3mt.kasmra@foresto.suomi.net>,
> Tuomas Kasmra <kasmra@ne-spamon.gmail.com> wrote:
>>2008-09-04, Charles M skribis:
>>> When you type
>>>
>>> ESC :
>>>
>>> and then then UP Arrow to get a previous command, how can
>>> you edit that command, e.g. I want to change the beginning
>>> of the command, so I might try ESC :0 (beginning of line in VIM),
>>> but the ESC takes you out of the given command.
>>>
>>>
>>> CMM

>>
>>Just use arrow keys or <home> key to move. There should be no need to
>>press <esc> again at the command line.

>
> Or use q:
> (instead of ESC
>


I didn't know you could get a command history that way. Cool.
Reply With Quote
  #5  
Old 09-04-2008, 01:39 PM
Kenny McCormack
Guest
 
Default Re: [vim] Edit the command line

In article <slrngc0142.1b7o.CharlesM@199.sub-75-204-7.myvzw.com>,
Charles M <CharlesM@199.sub-75-204-7.myvzw.com> wrote:
....
>> Or use q:
>> (instead of ESC
>>

>
> I didn't know you could get a command history that way. Cool.


It is one of the niftier features of VIM. Definitely worth the price of
admission. Note that there are bunch of related ones: q/ (edits the
list of things searched for) and others (but I don't think I've used any
other than q: and q/).

Reply With Quote
  #6  
Old 09-04-2008, 05:04 PM
Gary Johnson
Guest
 
Default Re: [vim] Edit the command line

Charles M <CharlesM@199.sub-75-204-7.myvzw.com> wrote:
> On 2008-09-04, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> In article <slrngbvtfa.3mt.kasmra@foresto.suomi.net>,
>> Tuomas Kasmra <kasmra@ne-spamon.gmail.com> wrote:
>>>2008-09-04, Charles M skribis:
>>>> When you type
>>>>
>>>> ESC :
>>>>
>>>> and then then UP Arrow to get a previous command, how can
>>>> you edit that command, e.g. I want to change the beginning
>>>> of the command, so I might try ESC :0 (beginning of line in VIM),
>>>> but the ESC takes you out of the given command.
>>>>
>>>>
>>>> CMM
>>>
>>>Just use arrow keys or <home> key to move. There should be no need to
>>>press <esc> again at the command line.

>>
>> Or use q:
>> (instead of ESC
>>

>
> I didn't know you could get a command history that way. Cool.


You can also enter that mode from the command line by pressing Ctrl-F.
I find <Esc> more natural than Ctrl-F, though, so I set the 'cedit'
option like so:

set cedit=<Esc>

See

:help cedit
:help cmdwin
:help history

For easier editing on the command line itself, you can create a set of
emacs-like edit-key bindings. See

:help emacs-keys

--
Gary Johnson
Reply With Quote
  #7  
Old 09-05-2008, 04:38 AM
John Beckett
Guest
 
Default Re: [vim] Edit the command line

Charles M wrote:
>and then then UP Arrow to get a previous command, how can
>you edit that command, e.g. I want to change the beginning
>of the command, so I might try ESC :0 (beginning of line in VIM),
>but the ESC takes you out of the given command.


It's the featured tip this month at:
http://vim.wikia.com/wiki/Main_Page
http://vim.wikia.com/wiki/Using_command-line_history

John

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 06:53 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.