logoalt Hacker News

ahmedfromtunislast Thursday at 9:18 AM11 repliesview on HN

Using the terminal becomes much more cozy and comfortable after I activate vim-mode.

A mistake 3 words earlier? No problem: <esc>3bcw and I'm good to go.

Want to delete the whole thing? Even easier: <esc>cc

I can even use <esc>v to open the command inside a fully-fledged (neo)vim instance for more complex rework.

If you use (neo)vim already, this is the best way to go as there are no new shortcuts to learn and memorize.


Replies

piekvorstlast Thursday at 11:18 AM

This reminds me of an excerpt from an old Emacs manual:

    . . . if you forget which commands deal with windows, just type @b[ESC-?]@t[window]@b[ESC].
This weird command is presented with such a benevolent innocence as if it's the simplest thing in the world.

I think the better advice for command-line editing would be to set up the mouse.

show 1 reply
commandersakilast Thursday at 10:07 AM

I've been a (n)vim user for 20+ years now, but I hate vi-mode in the shell. However if I feel that I need to do a complex command, I just do ctrl-x+e to open up in neovim (with EDITOR=nvim set). I find it a good middle ground.

show 4 replies
rzmmmlast Thursday at 9:59 AM

Oh wow I didn't know about this, thank you. The underlying feature is called "readline vi-mode" for folks who want to search more about it.

penguin_boozelast Thursday at 11:32 AM

> <esc>cc

Doing control+o in insert mode temporarily places you into normal mode so that you can execute one normal-mode command, and then go back to insert mode again--no need to hit 'i' again.

So, instead of '<esc>cc', '<c-o>S'.

show 2 replies
dbtclast Thursday at 4:42 PM

I use vim a lot but not on the shell

A mistake 3 words earlier?

meta-bbbd (not as elegant, I admit)

delete the whole thing?

ctrl-ak (this is even quicker than vim, especially if capslock is mapped to ctrl)

the control-based emacs movements work system-wide on macos btw. I am using ctrl-p and ctrl-n to go up and down lines, ctrl-a and ctrl-e to go to beginning and end of lines while writing this comment in by browser (which has vimium extension)

Sometimes I wish vim just had full emacs bindings while in insert mode. But I don't like to mess with defaults too much.

I keep thinking I should give vim readline a try though, so maybe today. Thanks for the comment.

show 1 reply
commandlinefanlast Thursday at 7:39 PM

I've never understood why emacs mode became the default. "set -o vi" is the _first_ command I type in a new shell.

show 1 reply
nidnogglast Thursday at 1:34 PM

I've been a vim/nvim casual user for the past year or two, and I still feel as if I'm slightly less proficient in it for the amount of time that I put into it.

I really need to get around to playing with it more. I just hope that especially now with genAI that it's not too late for learning it further.

exceptionelast Thursday at 10:32 AM

   <esc>3bcw
What is your keyboard layout? This looks like a crime against humanity on a regular qwerty kb.
show 2 replies
ruptwelvelast Thursday at 1:00 PM

The <esc>v has been such a lifesaver at times when having to execute/modify super complex commands!

looshchlast Thursday at 9:10 PM

i went even further and use neovim as my multiplexer

Ferret7446yesterday at 2:27 AM

Eh, it's not that different from the default readline commands

A mistake 3 words earlier? No problem: <esc>3 Alt-b Alt-d

Want to delete the whole thing? Even easier: Ctrl-U

I can even use Ctrl-X Ctrl-e to open the command inside a fully-fledged EDITOR instance for more complex rework.