4 ms·
To automatically enable this for all term applications, create a file .inputrc in $HOME and put this: set editing-mode vi $if mode=vi set keymap vi-command
by amitutk 12y ago
To automatically enable this for all term applications, create a file .inputrc in $HOME and put this:
set editing-mode vi
$if mode=vi
set keymap vi-command
"gg": beginning-of-history
"G": end-of-history
set keymap vi-insert
"jj": vi-movement-mode
"\C-p": history-search-backward
C-L: clear-screen
- deleted 12y ago[deleted]
- dorfsmay 12y agoThanks! You really only need the first line for the apps to start in vi mode automatically. Knowing the key combination to toggle is still useful for when pairing etc...
- Pwnguinz 12y agoWhat happens if you don't set keymap "gg", "G", etc? Would they not work, or...? (Currently not on a *nix machine to be able to test it out, or else I wouldn't ask such a simple question :P)
- madsravn 12y agoMy guess is, that you redefine them to mean the semantically same in a new domain. What I mean is that gg and G lets you go to the top of the file and to the bottom of the file, right? But on the command-line, what is the top of your file? And what is the bottom?
- pmr_ 12y agoI can only speak for the Emacs capabilities of readline: all commands which would usually change the line (previous/next-line, beginning/end-of-buffer) will use the history as the buffer. All of them preserve the line you are currently typing, which will be the end of the buffer.
- oftenwrong 12y ago"G" works with a number for recalling shell history. For example, "4G" recalls the fourth command in the shell history. However, "G" alone without a number does not work as it does in vi (jump to last line). I suppose that was the desired functionality. It makes sense for "gg" to be absent, as it is not a vi command. It is a "vimism". The typical vi command for moving to the first line is "1G".
- mijoharas 12y agoAs well as ~/.inputrc (which I have "set editing-mode vi" within), there is also ~/.editrc which has support for the editline library (which some repls use). I have my ~/.editrc set to the following to give me a vim-like editing environment bind -v bind "^R" em-inc-search-prev bind \\t rl_complete (NOTE: I forget the source for this, it was something like oh-my-vim but I can't find exactly where it was from.)