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.
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. :)
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.
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
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.
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.
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.
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.
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
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 thea
register 10 times
I am logged into various servers via ssh constantly and nano or vim (or at least vi) are installed pretty much by default everywhere.
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.
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
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.
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”
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.
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?
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.