I’d like actual examples instead of “I work faster”, something like “I can move straight to the middle of the file with 7mv” or “I can keep 4 different text snippets in memory and paste each with a number+pt, like 2pt”, things that you actually use somewhat frequently instead of what you can do, but probably only did once.

32 points

Where editors usually have editing shortcuts, vim has an editing grammar.

So you can copy (or select, or replace, or delete, or any other editing verb) N arguments or blocks or lines or functions or any entity for which vim has an editing noun, or around or inside either of these, and you only need to remember a few such editing verbs and nouns and adjectives in order to immediately become much more effective.

It’s so effective that switching back to a regular editor feels annoyingly clunky. (I guess that’s why many offer vim plugins these days.)

Better: you can record entire editing sentences and replay them. Ever had to make the same change on dozens of lines? Now you can do it in seconds.

Now of course, replaying a sentence, or several sentences, is also a sentence of its own that you can replay in another file if you want.

It’s neat. :)

permalink
report
reply
6 points

Better: you can record entire editing sentences and replay them. Ever had to make the same change on dozens of lines? Now you can do it in seconds.

I think my first experience with that kind of macro recording/replay was with Dwarf Fortress, of all things.

permalink
report
parent
reply
7 points

I had no idea DF had macros but it makes so much sense.

permalink
report
parent
reply
3 points

CTRL R starts recording the inputs, press again to stop. CTRL P plays it. Makes digging magma shafts through several floors, then setting up the pumps, so much easier

permalink
report
parent
reply
3 points

This is the comment that best explains it for me. I started with vim for comfort (less movement to mouse, and less reliance on modifier keys). The editing grammar is something I didn’t really understand until I started gradually using it, but now it’s the thing I most appreciate. I don’t know if I’m necessarily faster in vim, but my work is more fluid. The editing doesn’t interrupt my thinking as much.

permalink
report
parent
reply
1 point

Ever had to make the same change on dozens of lines? Now you can do it in seconds.

This would be a big advantage… except multiple cursors were invented so I can easily do that without having to memorize a whole new editing language.

permalink
report
parent
reply
7 points

Multiple cursors are fantastic for certain use cases, but will not help you when each line needs a different input – if you’re swapping arguments in function calls, if you’re replacing one bracket type with another around contents of arbitrary length, etc.

Mind you, if your objective here is to not learn a new thing, then you can just go ahead and do that, you don’t need an excuse.

permalink
report
parent
reply
3 points

Yeah, I usually do that with regexp replacement in other editors, but sometimes it’s too hard to express as a regular expression

permalink
report
parent
reply
2 points

That’s just one thing the editing language does, though. There’s no single feature you can point to as the smoking gun; it’s all the small advantages added together that make vi worthwhile.

permalink
report
parent
reply
21 points

Honestly the best bit is just not feeling the need to take my hand off the keyboard and use the mouse. I don’t think I can quantify the time saved, but I can tell you I really notice when I’m using software that makes me have to switch.

permalink
report
reply
4 points

Yeah when my hand goes to the mouse it feels like I’ve broken a combo or streak. Like I’ve switched from an active to a passive mode. The mouse is for clicking and scrolling, like reading email and webpages

permalink
report
parent
reply
2 points

The Acme editor (and Sam) begs to differ. Sadly it’s hard to find a mouse that can do mouse chording today.

permalink
report
parent
reply
-2 points

So, like every text editor also without a beep-mode?

permalink
report
parent
reply
9 points
*

I don’t know if this comment comes from ignorance or snarkiness but it’s really not the same. Other editors add in hotkeys over time to perform a single function.

Vim key bindings are actually a terse text manipulation language where you can form arbitrary “sentences” like:

  • ciw - change the current word, meaning remove it and then enter insert mode

  • D - delete until end of line

  • dt: - delete everything between the cursor and the next colon on this line

  • 10"ap Paste the contents of the a register 10 times

permalink
report
parent
reply
17 points

I am logged into various servers via ssh constantly and nano or vim (or at least vi) are installed pretty much by default everywhere.

permalink
report
reply
6 points

That doesn’t explain a preference for vi(m) over nano, tho

permalink
report
parent
reply
4 points
*

How could I live without dd, vap, 99j, 99k, 555gg, zt, zz, zb, [, ]?

If these were the only vim commands it would still be better than Nano.

permalink
report
parent
reply
2 points

For me it’s plain ol’ tT and fF. I get frightfully bored when a text field makes me use Home/End/arrows 😪

It’s like, I know where I want the cursor, just let me GO there. And no manually moving my cursor into position is not it. It’s so not it

permalink
report
parent
reply
1 point

Nano is extremely basic, it’s not really the right comparison. Vi competes well with heavyweight GUI editors and IDEs, yet is available about as ubiquitously as nano.

By learning vi, I can have my no-compromises favorite editor equally available to me locally or remotely. The terse, low-chord (looking at you, nano) editing language in vi means I’m not even that hampered when I do remote editing from my phone.

permalink
report
parent
reply
15 points

Its not so much about the time saved its about being allowed to stay in a mental state of flow since all actions in Vim and similars are built from foundational navigation language chunks. It feels less like editing and more like communicating. All these random little “I can do this command” is just people trying to show examples of how the language of editing to do weird and interesting things. So the answer isn’t so much “I work faster” in Vim as it is “I work with less mental overhead in Vim”

permalink
report
reply
11 points
*

Just being able to jump to the top of the file, bottom of the file, beginning or end of the line, or directly to a regex pattern match or particular character already gives me some of the same satisfaction as a video game with really tight movement controls. (I also like being able to jump to lines by number, manipulate lines by number or range, and I like being able to get to the top, bottom, or middle of the screen with one or two keypresses.)

In the same vein, deleting arbitrary lines at a time, performing external operations only on lines that match a particular pattern, and saving macro recordings of repetitive manual changes all feel like multiplicative powerups. Heck, incrementing and decrementing with ^a and ^x feels like one more little cheat code. Bouncing on parentheses with % makes structured files easy to get around in.

These are all things I’ve done with some regularity over the years.

permalink
report
reply
6 points

Bouncing on parentheses with % makes structured files easy to get around in.

That’s something I wasn’t aware you could do in vim. % jumps to the next parentheses character, whether ( or )? Does it work with brackets and curly braces too?

permalink
report
parent
reply
6 points

So far as I’m aware, yes. As a C engineer, it’s also useful for jumping from #ifdef to #endif .

permalink
report
parent
reply
4 points

Not just the next parenthesis that appears, It jumps to the matching one that opens or closes the one under the cursor. Hitting it repeatedly bounces back and forth around the text that pair of parentheses enclose.

It works not only with brackets and curly braces, but also with opening and closing tags in XML etc.

I feel like other editors must have an equivalent feature, though. I’d say the fact that vi can put such a specific action under just % rather than some nasty chord or mouse operation is what really makes it shine here.

permalink
report
parent
reply
2 points

It generally works with a wide variety of delimiters. There’s a widely used plugin to make it work with even more, including language-specific keyword pairs.

permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
parent
reply

Ask Experienced Devs

!ask_experienced_devs@programming.dev

Create post

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

Community stats

  • 1

    Monthly active users

  • 42

    Posts

  • 488

    Comments

Community moderators