Quick clarification for ksh - that's "set -o vi" you need to add to. For automatic vi keystrokes, edit $HOME/.profile or whatever your $HOME/$ENV script is. Ought to be noted that you can do the same with the Korn Shell (ksh). I'm sure all bash users will be familiar with: I think this is useful because zsh does not use readline like bash etc do. If you use zsh (and you really should!) you can add to your. # glob patterns without executing, eg: 'rm *x' # Edit options before rerunning previous command, eg: ls a b c -> ls -al a b c Some more interesting keys from my ~/.inputrc (works in cygwin/linux bash). This fixes that, and will insert 'p' when you type 'p'. # Needed because binding 'p' in command mode above wipes its insert mode # Option-up/option-down should also apply to insert mode # again will cycle through available completions. # Pressing tab will list all completions & select the first one. # Keymaps for when we're in insert (i.e., typing stuff in) mode # to set plain up/down to do a history search by default. # Feel free to bind to whatever you want. # have mapped "option cursor up" to "\033\033[A" and "option cursor down" to # In OS X's Terminal.app preferences, I have 'Use option as meta key' off, and # which start with the prefix you've entered, rather than just cycling through # When hitting option-up/option-down, cycle through the previous commands # Insert the arguments from the last command # Keymaps for when we're in command mode (e.g., after hitting ESC) # on menu-complete, first display the common prefix, then cycle through the # Show all completions as soon as I press tab, even if there's more than one My own personal ~/.inputrc, with comments on every line, can be used as an example of customizing your own shell. In your ~/.inputrc, a line with set keymap vi-command means that mappings below that line apply to command mode a line with set keymap vi-insert means that mappings below that line apply to insert mode. When customizing your Vi-style kemappings, be mindful of which editing mode your keymap applies to. It is recommended that you run the command once with insert mode active, and once when command mode is active.Ī reference to adjusting the options and mappings of the readline library most shells use for text editing can be found in the readline man page, or in the GNU bash man page. Important: the displayed keybindings will change depending on whether you're in insert or command mode when you execute the command. In bash, to see a list of the keymappings currently active, use the command bind -p | grep -v '^#\|self-insert\|^$'. You may want to keep a cheat sheet of default keymappings handy, since they do differ from Vi/Vim occasionally. By default, you're in insert mode press Esc to enter command mode. Restart your terminal and you'll have Vi keybindings. To enable Vi-mode, edit (or create) the file ~/.inputrc or /etc/inputrc and add the following lines: Not only will the keybindings match what you're used to, but you'll also have modal editing, just like Vi. It's possible to tell your shell to use Vi shortcuts instead. Many Unix shells (bash, zsh, etc.) come with keyboard shortcuts enabled: C-a jumps to the start of the line, C-e jumps to the end, and so on. Tip 1220 Printable Monobook Previous Next
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |