Wednesday, February 16, 2011

Re: How to move to beginning of command line

Jeremy, Wed, Feb 16, 2011 at 10:04:15AM -0800:
> When typing a command, (i.e., su/.../.../) how can I jump around on the
> command line without using the arrow keys. That is, how can I jump to the
> beginning, or the end, or move backward/forward? In a terminal, I can just
> use the CTRL-A and CTRL-E to go to the beginning and end of the command. Is
> there something similar in Vim?

CTRL-B or <Home> moves to the beginning of the command line; CTRL-E or
<End> moves to the end. See :h c_CTRL-B and :h c_CTRL-E.


By the way, since you mention the shortcuts that you use in the
terminal, you might find it useful to know that if your shell uses
readline for command line editing (such as bash), you can set it to use
vi-style modal editing commands. The CTRL-A and CTRL-E shortcuts are
Emacs-style shortcuts, which are what readline uses by default. If you
turn on vi mode, you can hit <Esc> when editing a shell command to enter
normal mode. From there, you can use vi shortcuts like dd to delete the
command, p to paste, w and b to move forward and backward by words, etc.
v will open the current command line in your $EDITOR (Vim, of course)
for interactive editing.

In bash, "set -o vi" will turn on vi mode. You can make it permanent by
putting it in your bashrc. You can also put the following in
$HOME/.inputrc to make vi mode the default in all programs that use
readline for command editing:

set editing-mode vi
set keymap vi

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

No comments: