Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash's vim mode, not vi

Tags:

bash

vim

vi

I was fascinated when I discovered vi-like bash's editing mode. One can easily toggle it by issuing set -o vi command. But is there any way to toggle vim-like mode?

I mean when you are in a vi-like mode you can press v key and edit your commands in a fully functional vi editor's window but I would like to know how to force bash to start vim editor instead of vi because of the perks vim provides us (visual selection, additional commands etc)?

like image 928
mesmerizingr Avatar asked Apr 22 '14 21:04

mesmerizingr


People also ask

How do I set bash to VI mode?

The bash shell (again, via GNU Readline) is able to provide this functionality for us. In order to enable it, you run the command $ set -o vi.

How do I switch to command mode in vim?

To go back to COMMAND mode, you type the esc key. vim starts out in COMMAND mode. Over time, you will likely spend more time in COMMAND mode than INSERT mode. Note that all commands mentioned below (except for arrow keys) only work in COMMAND mode.

What is vim restricted mode?

When invoked as gvim or gview, vim will start the GUI version, under X Windows or in whatever other graphical interface is appropriate. If a leading r is prepended to any of the names, vim enters "restricted" mode, where certain actions are disabled. vim has a large number of command-line options.


1 Answers

If you set EDITOR variable, in bash you can press Ctrl-x ctrl-e to edit your current command line in your EDITOR e.g. vim

EDIT

the ctrl-x ctrl-e is for emacs mode commandline editing, which is the default one. If you have already set it to vi mode, you could do what you have said, pressing the v. If you want to open the cmd line in vim, you have to set the EDITOR variable (in your .bashrc for example)

Personally I edit command line in emacs mode, even though vim is my main (and only) editor.

like image 84
Kent Avatar answered Oct 15 '22 20:10

Kent