Using normal-mode motions in command-line mode in Vim

前端 未结 6 829
旧巷少年郎
旧巷少年郎 2021-01-30 02:07

Is modal editing possible in command-line mode?

Some examples:

  • After writing !ls ~/foo/bar I want to db to delete bar
6条回答
  •  春和景丽
    2021-01-30 02:35

    Plugins for "Normal mode"-like Command-line editing

    emacscommandline makes the command-line mode behave more like the Unix command line, by adding Emacs-style mappings (like in the Bash shell). Some of the mappings just map existing vim commands, but the rest implement functionality that is not available natively.

    conomode.vim implements a kind of Normal mode ( "Cmdline-Normal mode" ) on top of the Command line. Purpose is similar to the cmdline-window (q:), but navigation and editing can be done in-place. Of course the cmdline-window is much more powerful.

    Conomode does not replace Vim's native emacs-style command line editing, it just adds one key: CTRL-O (see below).

    • enter with c_ (press CTRL-O while in Command-line mode)
    • mode indicator is a colon ":", moved along with the cursor, hiding the char under it
    • quit to Cmdline-mode with I, i, a, A, : or any unmapped key (which then executes or inserts itself), or wait 60 seconds.
    • quit to Normal mode with Esc

    (Admittedly, I don't understand the point of this plugin, since instead of hitting Ctrl+O to enter its Cono-mode, you could just as quickly pop up the command-line window with Ctrl+F.)

    There might be other plugins out there. → https://www.google.com/webhp?q=command-line+editing+plugin+vim

    Instead of employing a full-blown plugin, or as a complement to it, you can define your own mappings. → See my other answer.

提交回复
热议问题