7 ms·
set -o vi Vi keys in the editor, Emacs on the CLI? This has never made any sense to me. https://popcon.debian.org/main/editors/by_inst https://popcon.debian.o
by itomato 9y ago
set -o vi
Vi keys in the editor, Emacs on the CLI? This has never made any sense to me.
https://popcon.debian.org/main/editors/by_inst https://popcon.debian.org/main/editors/by_inst
- mpblampo 9y agoThank you for this! I had no idea this existed. It is perfect for vim users. Very happy that I can now jump around to my heart's content without learning a new set of keyboard shortcuts.
- funkymike 9y agoEven better is to create a .inputrc configuration file. This is used by readline so it will affect your shell and some other utilities. You can do even more in there too. For example I use this: set editing-mode vi # Up and down arrows keys search history based on what is already typed. "\e[A": history-search-backward "\e[B": history-search-forward
- deleted 9y ago[deleted]
- ggm 9y agoIts a historical artifact of how in-line edit emerged as a thing for most people. MIT had huge influence in the development of window systems (X10/X11) and adopted emacs string edit mode in most type in boxes. Bash came from a community which had a strong emacs usage. So, the default in both the window system and in the bash shell, was emacs, even if you use ed/ex/vi Because most people used awk/grep/sed/ed/ex/vi the regex format tended that way. But enough people used tcsh or bash in emacs by default, that shell and omnibox (when browsers eventuated) edit defaulted to emacs. Thats my theory: accidental happenstance and defaults.
- deleted 9y ago[deleted]
- SmirkingRevenge 9y agoAnd if I'm not mistaken, during that time, the ctrl key was typically where caps lock is today (maybe just on certain machines?) - and that is what influenced the frequent use of ctrl for key shortcuts in libraries lile readline.
- ggm 9y agomay well be. not that escape is so far away from a pinkie, for the modal people (like me)
- SmirkingRevenge 9y agoIt pretty far away, compared to capslock. Especially on modern laptops.. lile touch bar macs that actually remove the the entirely
- ggm 9y agoHateful. Annoying. Thank goodness for kbd remapping
- hoosieree 9y agoClose: https://en.wikipedia.org/wiki/Space-cadet_keyboard#/media/File:Space-cadet.jpg https://en.wikipedia.org/wiki/Space-cadet_keyboard#/media/Fi...
- okket 9y agoI am a fan of vi/vim, esp. as a remote shell editor. But the vi support in readline CLIs is overkill IMHO. I don't see the need for the 'extra power' of vi there, esp. the modes. A few well known keyboard short cuts are just fine for a CLI. This also works the other way around: A few EMACS based shortcuts are the better 'lowest common denominator' than to force vi modes on everyone. Many are not willing to go down the vi/vim path, for various reasons.
- jethro_tell 9y agoHOW DO YOU EXIT THIS SHELL??
- imiric 9y agoI disagree, and find the vi mode (and extended Vim bindings) very useful in the shell. Consider a long cURL command split over several lines. If every option is on a separate line, removing one is a `dd` keystroke away. Adding a new option is also very efficient. Extended Vim bindings will also allow you to delete everything within brackets/delimiters (e.g. `di"`) or delete everything up until a character, etc. These are all simple keystrokes that translate well to the shell. You could also open the command in your $EDITOR anyway (bound to `V` for me), but I reserve that for really long and unwieldy commands.
- mooreds 9y agoI came here to post that, glad you beat me to it. Reaching for that control key? Ouch. Though I guess when you use vi keybindings, you are occasionally reaching for the escape key. But, there is something to be said for meeting people where they are. If folks know the emacs keybindings, let them 'control' away!
- Lio 9y agoAs a dyed in the wool Vi user. I still want ctrl where I can reach it easily. Ctrl-[ for escape and when in Insert mode, ctrl-h backspace; ctrl-w delete word; ctrl-u delete line; Ctrl-m return; ctrl-i tab, etc.
- mooreds 9y agodifferent strokes for different folks. I did not know about those insert mode keystrokes. Thanks!
- Lio 9y agoYeah, I have some problems with RSI in my right wrist (stop sniggering at the back). I think it's mostly down to the way I twist to reach backspace rather than move my whole hand from the home row. Ctrl-h, Ctrl-w and Ctrl-m really help with that. The only problem I have is that I don't know how to remap Ctr-m to return in X windows applications. I use Karabiner on a macOS and Gnome Tweak tool on Linux for the others. It's somewhat frustrating to have different shortcuts in the terminal, where I spend most of my time and the browser where I spend most of the rest. Edit: (If anyone can suggest a good way of mapping ctrl-m to return in Linux browsers I'd really appreciate it.)
- SmirkingRevenge 9y agoIm a broken record in this thread right now... for goodness sake, remap capslock to ctrl!!
- wyclif 9y ago
- zeveb 9y agoemacs Why not just use emacs everywhere? I suppose if you use spacemacs (which has vim keybindings) then you might want to 'set -o vi' on the command line. Emacs has Org-mode & Magit, each of which should be reason enough to switch. Then there're notmuch, gnus, slack-mode, eww … Seriously, emacs really is a more powerful environment[0]. Modern vim tries to be as flexible as emacs, but the language isn't as nice. E.g. Damian Conway's[1] simple example: function! ToggleSyntax() if exists("g:syntax_on") syntax off else syntax enable endif endfunction nmap <silent> ;s :call ToggleSyntax()<CR> would be: (defun toggle-syntax () (syntax (not syntax)) (global-set-key (kbd "M-C-s") toggle-syntax) in a hypothetical elisp for a vim-like editor[2]. In his article he refers to vimscript a more humane than elisp, but I think this simple example shows he's wrong. His next example is a command to capitalise a line, centre it, then move down: function! CapitalizeCenterAndMoveDown() s/\<./\u&/g "Built-in substitution capitalizes each word center "Built-in center command centers entire line +1 "Built-in relative motion (+1 line down) endfunction nmap <silent> \C :call CapitalizeCenterAndMoveDown()<CR> I think this is a lot clearer: (defun capitalize-centre-and-move-down () (interactive) (upcase-region (line-beginning-position) (line-end-position)) (center-region (line-beginning-position) (line-end-position)) (forward-line)) [0] https://sites.google.com/site/steveyegge2/effective-emacs https://sites.google.com/site/steveyegge2/effective-emacs [1] https://www.ibm.com/developerworks/library/l-vim-script-1/index.html https://www.ibm.com/developerworks/library/l-vim-script-1/in... [2] For the real emacs, it's just font-lock-mode.
- 0x445442 9y agoI've used Emacs off and on for years now. But I can never get to that place where I get totally emersed because of the clunky terminal/shell story. I've tried eshell but what always gets me is having to C-c while in the terminal or eshell to get back to a different buffer. I prefer M-x and fuzzy function entry to key bindings and when I'm in a terminal buffer or eshell I always go for M-x which won't work. Any tips would be appreciated as I really like everything else about Emacs.
- sedachv 9y ago
- alan5 9y agoIf you modify your .inputrc with the following this should propagate to all of readline as well (e.g. python): set editing-mode vi
- CDRdude 9y agoWhat shell does that work in? On a mac, I have that set in my .inputrc and it does not propagate to python.
- zeptomu 9y agoBash. Actually it depends if the program uses libreadline - which should be the case for Python's REPL? You may try `rlwrap` which wraps programs without readline support.
- deleted 9y ago[deleted]
- foobarrio 9y agoThis is actually my preferred config. The reason being emacs shell buffers. I can interact with any shell tool using the full text editing features of emacs. I've had to interact with many Oracle databases via sqlplus. "sqlplus" is not a fun tool to use on the shell. However in emacs it is perfectly fine and works as well as the command line interfaces from PostGRE or MySQL. The inline shell also allows automatic history, block selecting and line truncate/wrapping controls across all tools. However for pure text editing, it's always vim for me. I've even found myself launching emacs+shell within tmux in one pane and vim in another.
- mulmen 9y agoSorry, unrelated nitpick but the name is PostgreSQL or Postgres. Postgres started in 1986 as a followup to Ingres and the name was meant to mean after-Ingres. The query language was later replaced with SQL and the name changed again to a portmanteau of Postgres SQL It's never PostGRE. https://www.postgresql.org/about/history/ https://www.postgresql.org/about/history/
- totierne2 9y agoHave you tried sqlcl from Oracle? 20 meg download (requires java). Up down left right work. Use sql hr@ instead of sqlplus hr @ (I am one of the developers.) . I should try it from within Emacs.
- debugxyz 9y agoNot enough people know about this config, bash/zsh compatible.
- zeptomu 9y agoAfter years of using Vim and Bash this was a relief that I learned way too late. For the lazy ones $ cat >~/.inputrc set editing-mode vi set keymap vi $if mode=vi set keymap vi-insert "jj": vi-movement-mode $endif Obviously you want to change vi-movement-mode to your favorite ESC style. E.g. searching through your last git commands becomes 'jj/git' then (you have to go to movement mode first, as insert mode is the default in the shell - which makes kind of sense).
- DavideNL 9y agoOne thing that annoys me on macOS is that "set -o vi" stops tab completion from working when logging in as root. $ sudo -i $ cd /va<tab> #results in "cd /var" $ set -o vi $ cd /va<tab> #results in: "cd /va "