在 Vim 的命令模式下导航

发布于 2024-11-27 20:59:13 字数 211 浏览 2 评论 0原文

我是一名长期学习 Vim 的 emacs 用户。 Emacs 允许我使用与任何其他缓冲区相同的导航键盘快捷键在迷你缓冲区(我在其中发出 Cx Cs 之类的命令)中导航。例如,即使在迷你缓冲区中,我也可以使用 Cf 向前导航一个字符。我也可以使用箭头键,但它们距离太远。

是否有任何键盘快捷键可以在 Vim 的命令模式 (:) 中导航,而无需使用箭头键——相当于 emacs Cf、Cb?谢谢。

I am a long time emacs user learning Vim. Emacs lets me navigate in the mini-buffer (where I issue commands like C-x C-s) using the same navigation keyboard shortcuts as in any other buffer. For example, I can navigate forward one character using C-f, even while in the mini-buffer. I could also use the arrow keys, but they are too far away.

Is there any keyboard shortcut to navigate in Vim's command mode (:), without using the arrow keys -- equivalent to emacs C-f, C-b? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

樱桃奶球 2024-12-04 20:59:14

添加到 Greg Hewgill 的答案中,您可以使用 q: 打开命令行窗口,您可以在其中使用任何 Vim 编辑功能。

Adding to Greg Hewgill's answer, you can use q: to open the command-line window, where you have any Vim editing power at your hand.

呆萌少年 2024-12-04 20:59:14

Vim 帮助中的一些内容:

CTRL-B or <Home>
        cursor to beginning of command-line
CTRL-E or <End> 
        cursor to end of command-line
CTRL-H              
<BS>        Delete the character in front of the cursor (see |:fixdel| if
        your <BS> key does not do what you want).
<Del>       Delete the character under the cursor (at end of line:
        character before the cursor).
CTRL-W      Delete the |word| before the cursor.  This depends on the
        'iskeyword' option.
CTRL-U      Remove all characters between the cursor position and
        the beginning of the line.  

Some from the Vim help:

CTRL-B or <Home>
        cursor to beginning of command-line
CTRL-E or <End> 
        cursor to end of command-line
CTRL-H              
<BS>        Delete the character in front of the cursor (see |:fixdel| if
        your <BS> key does not do what you want).
<Del>       Delete the character under the cursor (at end of line:
        character before the cursor).
CTRL-W      Delete the |word| before the cursor.  This depends on the
        'iskeyword' option.
CTRL-U      Remove all characters between the cursor position and
        the beginning of the line.  
挽心 2024-12-04 20:59:14

我的 .vimrc 中有这些

cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <M-b> <S-Left>
cnoremap <M-f> <S-Right>

I have these in my .vimrc

cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <M-b> <S-Left>
cnoremap <M-f> <S-Right>
灼疼热情 2024-12-04 20:59:14

使用默认的键绑定,vim 不提供命令行编辑的非箭头键导航。不过,请参阅 :help cmdline-editing 了解如何使用 :cnoremap 命令设置备用键绑定的示例。

With the default key bindings, vim does not offer non-arrow-key navigation of the command line editing. However, see :help cmdline-editing for an example of how to use the :cnoremap command to set up alternate key bindings.

情仇皆在手 2024-12-04 20:59:14

我通过 分别导航上一个和下一个命令来实现这一点。

PS 我没有像 Tassos 那样进行任何自定义绑定。

I achieved that with <C-p> and <C-n> to navigate previous and next commands respectively.

P.S I'm not making any custom binding like Tassos did.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文