r/programming • • Sep 24 '15

Vim Creep

http://www.norfolkwinters.com/vim-creep/
1.2k Upvotes

844 comments sorted by

View all comments

147

u/Darkmoth Sep 24 '15

A colleague of mine was talking up the virtues of Vim (we're a Windows shop), so in response I decided to learn all the keyboard commands of Visual Studio - there are eight-hundred and thirteen. I'm a perverse bastard.

I'm still working at it, but ye gods has using the keyboard made me faster. In Visual Studio. Run the test suite? BAM. Switch to Team window and commit? BAM. Switch tool windows? BAM taptaptap (don't ask).

Ironically, I have sort of convinced myself that my co-worker probably has a point.

147

u/jollybobbyroger Sep 24 '15

A big difference between Vim and your 813 hotkeys is that Vim has a structure to the key bindings. Where you have to memorize individual hotkeys for each command in VS, Vim commands are simple languages. So when you learn a new action or scope, you can combine that with everything else you already know.

E.g. I know how to indent the entire file. Cool. Then I learn about the block scope, so I immediately know how to indent the block. Then I learn how to format text to be confined within the set text width. Now I immediately know how to format the entire file and a text block. Then I learn about the "from cursor to character X" scope and now I can perform all known actions on this scope as well.

Note that the scopes are not like selections. They are controlled by keyboard input, even though in Vim, selections are just another action as well and now that I know the key for that, I know how to select any of the scopes I already know.

For VS and other IDE's and editors, each permutation of these scopes and actions would require its own hotkey, or it can only work with a selection and for that you have to spam ctrl+arrow/pg{up,down}/{home,end}, which to a Vim user are clunky and imprecise.

This is of course just scratching the surface of all the power of Vim that are accessible through a few key presses..

60

u/Darkmoth Sep 24 '15

A big difference between Vim and your 813 hotkeys is that Vim has a structure to the key bindings

No, I agree. That was my first thought when looking at them all. It'll take quite a while to memorize the ones I need (which isn't really all 813). To be fair, that also makes it funnier.

5

u/temp3298463 Sep 25 '15 edited Sep 25 '15

For VS and other IDE's and editors, each permutation of these scopes and actions would require its own hotkey, or it can only work with a selection and for that you have to spam ctrl+arrow/pg{up,down}/{home,end}

I don't know what other editors you're using, but mine lets me select a block, the entire file, or every occurance of a word with a single keystroke.

8

u/jollybobbyroger Sep 25 '15

What about "from the cursor to the {first,last} occurrence of character X", or within/around/surrounding the pair of quotes, parenthesis, html tag, brackets, sentence, function argument, block, paragraph .. ?

3

u/dpash Sep 25 '15

"Here to where I was before"

→ More replies (2)

3

u/temp3298463 Sep 25 '15

within/around the surrounding pair of parens, HTML tag, brackets, function arg (mostly), block (indentation-delineated or brackets-delineated), and paragraph are all a single keystroke.

To the first/last occurance of X it doesn't do, and is the one thing from VIM that I've seriously missed.

Then again, it does have VIM mode, so I could just set it to behave exactly like VIM.

→ More replies (2)

2

u/Ran4 Sep 25 '15

That's the vim way of doing this though. It's really hard to compare things.

For example, going to the end of the line is super important for most editors, but in vim it's the overly clunky $. Why is it like this? Because going to the end of the line in vim just isn't very important, there's so many other ways of doing things. E.g. o to get a new line below the current one, or yy to copy the entire line.

2

u/argv_minus_one Sep 25 '15 edited Sep 25 '15

from the cursor to the {first,last} occurrence of character X

Why would you want to?

within/around/surrounding the pair of quotes, parenthesis, html tag, brackets, sentence, function argument, block, paragraph .. ?

In IDEA, press Ctrl-W (“Extend Selection”) to do that.

→ More replies (12)

4

u/dpash Sep 25 '15 edited Sep 25 '15

Like when you learn about markers and then you're like "cool, I can reformat all the paragraphs from here to that marker I made earlier".

I can never remember how to make markers, which means I normally only ever use `` because I don't have an `a set. I should really look that up.

I do use Vim's block selection all the time. That's really handy.

6

u/blargtastic Sep 25 '15

Marks are insanely useful. How many times have you ever wanted to do something in one function that involves checking something from another? (Hint: all the time). Just do ma to set a as a mark right here and then go off and check the other function. Then do `a to return. The advantage is that in large files you often forget exactly where the original spot was when hunting down what you need to know, which wastes time.

8

u/Rusky Sep 25 '15 edited Sep 25 '15

Another awesome way to go back to where you were is ^o and ^i, which go backward and forward in jump history.

2

u/Amadan Sep 25 '15

Another awesome way to go back to where you were is :earlier 40m. :D (Note to self: commit more often... :P)

→ More replies (1)
→ More replies (1)
→ More replies (2)
→ More replies (1)

9

u/[deleted] Sep 25 '15

I don't use Vim itself (UI bugs me so I use Sublime Text with Vintageous) but I've always considered Vim's keybindings to be akin to a language.

4

u/tolos Sep 25 '15

"Your problem with Vim is that you don't grok vi."

akin to a language

I think most people would agree.

→ More replies (11)

30

u/VanFailin Sep 25 '15

This is why I don't really care about vim. The message here isn't that vim is some sacred greatest editor ever, but that forcing yourself to fully learn your tools will produce better results than just getting good enough.

0

u/[deleted] Sep 25 '15

[deleted]

→ More replies (2)

16

u/ChallengingJamJars Sep 25 '15

From another discussion, this learning-your-tools things includes things like word, it is a powerful document editor that some people think "just works", but then they run into all sorts of difficulties with formatting. But if you actually take the time learn what the internal model of a document is and work to that strength it is surprisingly good.

5

u/bilog78 Sep 25 '15

things like word, it is a powerful document editor that some people think "just works", but then they run into all sorts of difficulties with formatting. But if you actually take the time learn what the internal model of a document is and work to that strength it is surprisingly good.

Actually no. Yes, you can try and avoid many of the pitfalls of “naive” usage of Word, but even after you know it inside out it's not surprisingly good. Its internal model is fundamentally broken. Its editing capabilities are pitiful. Its formatting capabilities don't even match up with CSS2. A large part of this is that it tries to be too many things from a word processor to a desktop publishing application, failing miserably at all of them.

→ More replies (3)

3

u/b-rat Sep 25 '15

They could've set the tone better from the start because it has nothing to do with producing 4 line vs 10 page solutions

3

u/DEFY_member Sep 25 '15

These discussions always seem to boil down to an argument between those people who have worked around a vim or emacs expert, and those who haven't.

→ More replies (13)

2

u/pianohacker Sep 25 '15

That's a deeply crazy but entertaining quest.

So many mysteries like, "Why is Comment Selection bound to Ctrl-E Ctrl-C, Ctrl-E C, Ctrl-K Ctrl-C but not Ctrl-K C? Whoooo knows?"

0

u/[deleted] Sep 25 '15

[deleted]

→ More replies (3)

2

u/TheOldTubaroo Sep 25 '15

Wow, that's pretty incredible, I would have never expected VS to have so many shortcuts. Saving this for reference in case I'm ever using VS again, even if though I'll probably learn way less than the full 813.

→ More replies (10)
→ More replies (13)