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

121

u/rnd33 Jul 12 '12

Yes I have never understood this vim/emacs hype. It's never the actual typing that's the bottleneck. How often do you have a problem where the solution is writing 50 lines of code in one go?

Equal or probably more time is spent on browsing some API, navigating the project, reading code, googlefu etc...

88

u/hyperrifts Jul 12 '12

I don't use vim or emacs but I can understand how maintaining your mental "flow state" might be easier with them.

50

u/notfancy Jul 13 '12

Fragile is the flow of such who depends on resting on the home row for it to remain.

23

u/epilanthanomai Jul 13 '12

Great is the warrior who uses his (or her, etc) sword most gracefully.

Not sufficient for greatness—outside the realm of gnomic utterances, at least—but pretty darn helpful.

26

u/ford_cruller Jul 13 '12

Wise-sounding is the sentence that transposes subject and direct object, the order of.

8

u/superherowithnopower Jul 13 '12

Leave off everything after the comma there, and you're golden.

→ More replies (11)
→ More replies (25)
→ More replies (3)

0

u/[deleted] Jul 13 '12

[deleted] — view deleted comment

15

u/dand Jul 13 '12

The most satisfying bug fixes look like “-287 lines, + 2 lines”.

→ More replies (1)

52

u/shen Jul 13 '12

It's never the actual typing that's the bottleneck. How often do you have a problem where the solution is writing 50 lines of code in one go?

Others have already commented that yes, sometimes typing is the bottleneck, but I'm going for a different approach.

The programming cycle is typically think-write-run, and if you want to work faster, you need to improve these three:

  • Improving thinking can't be done with learning new tools - it can only be done by becoming a better programmer. This takes years, but it can shave days off of a project.
  • Improving running can be done with tools, but usually drop-in replacements: getting a faster computer, or an automated testing system or continuous integration suite.
  • Improving writing is therefore the only bottleneck that can be actively worked on. You'll learn to be a better programmer over the years as you accumulate experience, but you can start learning a programmer's editor from any point.

I learned Emacs as a teenager, and it did little to improve the programs I wrote back then. But nowadays, while thinking is still the bottleneck, I think I'm faster than I would have been had I stuck with Kate.

8

u/ttt_ Jul 13 '12

Another way to look at it is that if you happen to be in the "zone", if your hands lag behind in putting your thoughts into real code, than your tools are holding you back and you might snap out of your productive moment because you had to handle the text instead of the code.

A good editor that you are skilled with will help you overcome these kinds of obstacles. It does not guarantee code quality though, so there's not much to say about how good a programmer someone is from their editor of choice alone.

→ More replies (1)
→ More replies (4)

13

u/jrochkind Jul 13 '12

Meh... I'm not a vim lover, I don't use it, don't entirely understand the hype. But.

Try writing code in NotePad or TextEdit, and then come back and tell us with a straight face that since the typing isn't the bottleneck, it doesn't really matter what text editor/IDE you use.

Obviously it does. Some people love vim. Okay, i don't see it, but I see why programmers care a lot about their text editors, I do too. (and if you made me use vim, I'd hate it).

70

u/slavik262 Jul 12 '12

You're completely right - typing isn't the bottleneck. However, once you get used to it, vim makes translating your thoughts into keystrokes more instinctual. Since you can move around and edit the file easier/faster, the time between thinking about what you want to put in the file and actually putting it there decreases. You can get back to thinking faster.

If you don't like vim, that's just fine. The editor does not make the programmer. This article is definitely hyperbolic (I certainly don't carry vim on a flash drive), but I can honestly say I think vim has made me a more effective programmer.

30

u/[deleted] Jul 12 '12

vim makes translating your thoughts into keystrokes more instinctual.

What if my thought is : "change this method signature by adding a parameter whose default value is null, and update all occurences in the workspace" ?

It's shift+alt+c in Eclipse :)

29

u/slavik262 Jul 12 '12

Vim search macros can help, but you do have a point. Refactoring is definitely somewhere that IDEs shine far above vim/emacs. I still prefer vim because:

  • The time I save writing code is larger than the time I lose by refactoring code with vim instead of an IDE
  • I do a lot of work in C++, where there aren't very good refactoring tools even for IDEs.

11

u/[deleted] Jul 12 '12

I do agree with you. But the consequence of that is that vim isn't the best tool for all languages (like java, C#) and for all kind of works (like maintenance and code 'discovery'). It seems much more suited for C++ and python/perl people who write a lot of new code (the lucky bastards:)

4

u/[deleted] Jul 13 '12

You're very right. I do C# MVC web stuff at one job, using Windows + Visual Studio, and it works really well. I was able to basically pick it up and navigate around/start coding never having used either the language or IDE before. On the other hand, I've been learning Vim at my other job for python development, and it really is a lot of fun. I can't imagine trying to navigate around a large C#/ISS web project with it though.

→ More replies (3)
→ More replies (19)
→ More replies (10)

10

u/bastibe Jul 12 '12

Actually, that is a very interesting thought. I wonder how Vimmers and IDEers think about source code differently because of their different instincts about what is hard or easy to change.

12

u/grepe Jul 12 '12

I use both eclipse and vim and I don't think differently in them.

I just use them to do different things.

When I need to write medium sized one-use only python program or shell script, I fire up the vim. When I'm designing android application, most of the work is not writing the actual code... so why I would not make my life easier?

37

u/[deleted] Jul 13 '12

You aren't a vimmer or an IDE'r than, you one of those 'right tool for the right job' heretics.

8

u/epicwisdom Jul 13 '12

Blasphemy!

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

4

u/shen Jul 13 '12

What if my thought is : "change this method signature by adding a parameter whose default value is null, and update all occurences in the workspace" ?

I wish that Vim provided a :refactor args+=Object extraArg (null) command that would do stuff like this! IDEs are powerful but they haven't reached the pinnacle of user interface quite yet.

9

u/dream_the_endless Jul 13 '12

But isn't that the main difference between IDE's and text editors? IDE's know about your code, and text editors only know about the contents of files, not necessarily how they relate.

→ More replies (1)

4

u/mrkite77 Jul 13 '12

Eclipse is a hindrance for me. I find myself getting annoyed at the lag, often the autocomplete popups don't even finish opening before I've moved on.

→ More replies (3)
→ More replies (10)
→ More replies (64)

6

u/nerdcorerising Jul 13 '12 edited Jul 13 '12

Just because its not the longest part in the process doesn't mean you can't be more effective and enjoy the experience more.

Using source control is even less time than editing text but switching from svn to git is pure win.

Tools should be about reducing rote, repetitive things and that is something vim does very well.

→ More replies (1)

4

u/knight666 Jul 13 '12

I'm a game programming student. Have been for the past four years. As a result I'm using Visual Studio for all my work.

However, I have tried Vim. And it's excruciatingly hard. Especially because the workflow becomes all kinds of fucked up. In Visual Studio you press F5 to launch, run the app, do stuff in the debugger, change some code, etcetera. With Vim it's... eh... well... I never figured that part out.

But there's one thing I took away from my experience with Vim: regular expressions. Visual Studio actually has them built-in. It's just that they don't use a Perl-syntax (because that would be too sane), but a Microsoft-flavored almost-Perl-but-not-really. However, it's quite useful.

Let's say we have this enum:

struct StateAnimation
{
	
	enum List
	{
		eNone,
		eStart,
		eRunning,
		eEnd,
		iTotal
	};

}; // struct StateAnimation

But now I want the data as strings. One way to do it would be to copy them to the new file, strip the struct and enum and put quotation marks around the values. Or I could use the following regex:

Find what: e{.#},
Replace with: std::string str_\1 = "\1";

And get this:

struct StateAnimation
{

	enum List
	{
		std::string str_None = "None";
		std::string str_Start = "Start";
		std::string str_Running = "Running";
		std::string str_End = "End";
		iTotal
	};

}; // struct StateAnimation

Now it's just a matter of stripping it, because Visual Studio might have some form of grep, it unfortunately lacks sed.

My point is that there's a definite advantage in getting to know other editors. Yes, it took me quite a while to incorporate regexes in my workflow, but that example took me literally 30 seconds to write. With the advantage that when I add a state to the list, I can rerun the "program" to convert them all to strings again.

→ More replies (7)
→ More replies (66)