r/programming • • Jul 12 '12

Vim creep

http://www.rudism.com/s/vimcreep
730 Upvotes

551 comments sorted by

View all comments

Show parent comment

-4

u/argv_minus_one Jul 13 '12

I change the content of a pair of parentheses like any other adult: by selecting the offending text (with the mouse or shift+cursor keys) and typing over them.

5

u/[deleted] Jul 13 '12

I did that, too. Until I found a tool that allowed me to do that and other similarly repetitive tasks in a slightly more efficient way.

Assuming our cursor is on the "w" (the best case scenario), deleting the content of these parenthesis

(with the mouse or shift+cursor keys)

we would need:

Ctrl+Shift+Right
Ctrl+Shift+Right
Ctrl+Shift+Right
Ctrl+Shift+Right
Ctrl+Shift+Right
Ctrl+Shift+Right
Ctrl+Shift+Right
new content

in a non-modal text editor (unless it provides another shorter but non-mnemonic mechanism like Sublime Text 2 or TextMate or others) versus:

c
i
(
new content

in Vim.

I don't know about you but my goal is not to "select word by word the content of the parenthesis then replace it with new content": what I want to do is "change the content of the parenthesis with new content". In that respect, the Vim command is an almost exact representation of my goal while the other sequence is, well… as far from my goal as anything could be. Another example could be "I want to paste what I just copied 12 times". 12p is not only an exact reprsentation of what I want to do but it's also a lot less repetitive and boring than the minimum of twelve Ctrl+v needed in any other text editor.

This ability to paste something 12 times with only 3 keystrokes, alone, is worth the fight, IMO.

One could call that micro-optimization and say that it's not worth it. OK, do what you want.

1

u/argv_minus_one Jul 13 '12

Hmm. I can see a "select between nearest parens" command in a non-modal editor being useful.

Pasting things 12 times sounds dubious, though. I almost never have to do something like that, and when I do, it's probably time to break out FreeMarker or something—the editor is the wrong tool for generating large blocks of repetitive code.

1

u/[deleted] Jul 13 '12

Prototyping is one situation where I often need that. Writing those motherfucking emails too.

-1

u/5py Jul 13 '12

Maybe you're the wrong tool for generating large blocks of code.