Remix.run Logo
ahmedfromtunis 9 hours ago

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.

piekvorst 7 hours ago | parent | next [-]

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.

mikkupikku 2 minutes ago | parent | next [-]

I have yet to see a shell that has mouse enabled line editing support. It should certainly be possible though.

I do prefer vi bindings at the same time though. Vi bindings and mouse support complement each other well, you don't have to choose one or the other, just use whichever feels most natural and convenient in that exact moment.

JadeNB 4 hours ago | parent | prev [-]

> This weird command is presented with such a benevolent innocence as if it's the simplest thing in the world.

I think it's a question of context and familiarity. To a vim user, like me and, I assume, ahmedfromtunis, their examples do indeed seem simple and natural. Presumably, to an emacs user, the example you quote (if it's quoted literally—I don't use emacs and can't even tell) is just as natural, and assuming some comfort with emacs is presumably OK in a manual for the software!

Orygin 4 hours ago | parent | next [-]

> assuming some comfort with emacs is presumably OK in a manual for the software!

How do you get familiar with the software, if the manual expects you to be an expert in it already?

noisy_boy 2 hours ago | parent | next [-]

I got familiar with vi by reading a book that had the main vi commands listed out. First learnt how to quit without saving changes, the rest was just practice.

umanwizard 3 hours ago | parent | prev | next [-]

Not sure if it did at the time, but today emacs comes with a tutorial. You’re not expected to learn it by starting on page 1 of the manual.

Orygin 2 hours ago | parent [-]

Why not? I expect to learn how to use a software by reading its manual.

umanwizard 2 hours ago | parent [-]

Surely you can still do that, but starting with the tutorial will be easier and more efficient.

Pay08 3 hours ago | parent | prev [-]

By reading introductory material.

matthew-craig 2 hours ago | parent | prev [-]

The example confusingly includes some weird markup. It's just saying press `ESC-?` then type "window" to search for window commands. These isn't even valid in modern Emacs. The equivalent is `C-h` followed by `a` then type "window".

commandersaki 8 hours ago | parent | prev | next [-]

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.

void-star 4 hours ago | parent | next [-]

It’s strange. I have heard this from lots of others too. I think I am an anomaly here. I can’t live without shell vi mode

fp64 3 hours ago | parent [-]

You're not alone, I heavily rely on vi mode and often struggle if I'm on someone else's machine and can't use it. I always wonder how you're supposed to work without it but I never dare to ask

Linux-Fan an hour ago | parent [-]

`set -o vi` is quickly typed in anger...

busfahrer 5 hours ago | parent | prev | next [-]

I'm the same and in my opinion this is the best of both worlds. Taking the time to learn some of the regular (emacs-style) shortcuts is one of the best investments I've ever done. Even just CTRL+Y and the likes.

edit: And of course, CTRL+R, the best time saver of all

helterskelter an hour ago | parent | prev | next [-]

I used to hate it because I'd sometimes change modes without realizing it, but I began to appreciate it a lot more when I added a mode indicator -- a red 'N' on the rightmost side of the input line.

xtiansimon 6 hours ago | parent | prev | next [-]

Huh. I don’t use vi-mode for more than jumping to the beginning or end of a line, which I like a lot.

wbrd 6 hours ago | parent | next [-]

I'm a vim user but in the shell I use Ctrl-a and Ctrl-e to get to the beginning and end. If I need more editing I use Ctrl-x Ctrl-e to hop into vim.

void-star 3 hours ago | parent | prev | next [-]

It really shines for navigating history. <esc>/ searches history the same way as the editor search function

umanwizard 3 hours ago | parent | prev | next [-]

C-a and C-e are your friend.

irishcoffee 6 hours ago | parent | prev [-]

You mean, like the “home” and “end” buttons?

wholinator2 5 hours ago | parent | next [-]

Yeah but those are so far away, i have to hunt for them every time

6 hours ago | parent | prev [-]
[deleted]
sudonem 8 hours ago | parent | prev [-]

Agree.

I WANT to love it - and if I was only ever working on one, or a small number of systems that I was the only one working on I’d probably do it. I’m ALL about customizing my environment.

However ssh into various servers through the day (some of which are totally ephemeral), and having to code switch my brain back and forth between vim mode and emacs mode in the shell would just slow me down and be infuriating each time I connect to a new box.

dbtc an hour ago | parent | prev | next [-]

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.

rzmmm 8 hours ago | parent | prev | next [-]

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_booze 7 hours ago | parent | prev | next [-]

> <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'.

soraminazuki 41 minutes ago | parent | next [-]

Or just <C-u> in insert mode. <C-u> and <C-w> are standard Vim insert mode commands.

https://vimhelp.org/insert.txt.html#i_CTRL-U

ahmedfromtunis 5 hours ago | parent | prev [-]

The vim version is much easier, if you ask me: 3 strokes, 2 keys and 0 combinations.

The one you suggest however requires 4 strokes (ctrl then o then shift then s), 4 keys (ctrl, o, shift, s) and 2 combinations.

The "cc" sequence deletes the line and switches automatically to insert mode. To forgo the switch, the sequence then becomes "dd".

ratrocket 4 hours ago | parent | next [-]

Maybe I have my bash/readline vi mode configured specially to do this, but if I want to delete the entire line and type a new one (from anywhere in that line), I do something simpler than either of these alternatives:

<esc>S

Esc exits insert mode (of course) and capital S erases the line and puts you in insert mode at column 0 (just like in (n)vim, right?).

Like I said, maybe I configured that? But 'S' is standard vim-stuff... (I'm not able to double check my config at the moment).

[Edit: right after hitting submit I realized that my way is perhaps "arguably" simpler because I do have to hit shift to get capital S. So I'm also hitting three keys...]

maleldil 4 hours ago | parent | prev [-]

<c-o>S is also a vim sequence. The equivalent readline/emacs is <c-e><c-u> or <c-a><c-k>, or just <c-u> or <c-k> if you're already at the end/start of the line.

nidnogg 5 hours ago | parent | prev | next [-]

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.

exceptione 8 hours ago | parent | prev | next [-]

   <esc>3bcw
What is your keyboard layout? This looks like a crime against humanity on a regular qwerty kb.
ahmedfromtunis 5 hours ago | parent | next [-]

I use qwerty and azerty, and in both I never felt typing the sequence was any harder than typing any other regular word. Generally speaking, I prefer sequential "shortcuts" then multikey bindings.

sva_ 7 hours ago | parent | prev [-]

Instead of esc, type ctrl [

exceptione 7 hours ago | parent [-]

Does it help a lot? You've still got a three to type which is a crime, plus some letters, only to move 3 words. My typing skills are not great, but that sounds like an awful lot of work(?)

If I hit CTRL + ARROW_LEFT 3 times, I am done a lot faster I guess. But I am open to learn, do people really use that and achieve the goal significantly faster?

roxolotl 5 hours ago | parent | next [-]

I think it’s a difference in how people think. I can’t remember hotkeys. It just doesn’t compute. But with vim style bindings it’s much closer to writing a sentence. `3`, number of times, `b`, beginning of word, `c`, change, `w`, word. Yea it’s a lot. I cannot explain why it’s simpler for me to learn that than emacs style bindings but it is.

helterskelter an hour ago | parent [-]

Obligatory:

Your Problem with vim is you don't grok vi

https://stackoverflow.com/questions/1218390/what-is-your-mos...

gsinclair 7 hours ago | parent | prev | next [-]

I don’t love vi-mode, but I’ll address your comment.

Many people these days, including yours truly, have caps-lock mapped to ctrl if held or esc if tapped. That’s good ergonomics and worth considering for any tech-savvy person.

Instead of the 3b I would type bbb (because I agree with you that typing numerals is a pain).

So (caps lock)bbbcw isn’t bad. It’s better than it looks, because if you’re a vim user then it’s just so automatic. “cw” feels like one atomic thing, not two keypresses.

And importantly, it doesn’t involve any chords.

sva_ 2 hours ago | parent | prev [-]

We're basically playing a game: if you have to leave homerow hand position, you've lost

ruptwelve 5 hours ago | parent | prev [-]

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