r/ProgrammerHumor • • Apr 20 '15

vim

Post image
1.3k Upvotes

427 comments sorted by

View all comments

Show parent comments

86

u/noop__ Apr 20 '15

Because it let's me modify text faster, and more precisely than any other text editor in existence. And the portability (console based, *nix) makes it so I can have the same text editing workflow on all of my machines including the several thousand headless servers I manage.

28

u/iLostMyAcc Apr 20 '15

" it let's me modify text faster, and more precisely than any other text editor in existence." Do you have a example?

18

u/dysmas Apr 20 '15

It's not just being "faster" though, which lets be honest - is debatable.

The main thing that sticks me to vim is how it makes editing text effortless,

When I want to modify a given piece of text, the vim commands map very closely to my mental wishes, the changes just flow out.

10

u/nupanick Apr 20 '15

This is the right answer imho. It's not that vim somehow magically speeds up your workflow; I find for most tasks it takes about as long as a traditional editor still. It's just that vim's shortcuts are designed specifically to work the way you think when you work with text documents a lot. I've already internalized the shortcut for quickly cutting and pasting a single line, for instance, because I do that a lot when I'm making lists. And on top of this, it's console-based, which is a big plus over any graphical editor because it means I can use it on any machine.

26

u/noop__ Apr 20 '15

The vast array of movement and editing commands, and the modal interface with which they're presented allows almost anything to be just a couple of keystrokes away rather than being hidden away in the menus of gui text editors. Yeah, there's a steep learning curve to vim, but once you get the hang of it, you'll feel completely crippled in anything else (of course, until you get really good with $othereditor, but then you can make this decision for yourself, and I'll bet $10 you'll choose vim).

11

u/Dooey Apr 21 '15

Gui editors: Features are hidden away in menus Vim: Feature are hidden away in man pages.

I'm not sure which is better.

→ More replies (7)

10

u/mallardtheduck Apr 20 '15

just a couple of keystrokes away rather than being hidden away in the menus of gui text editors

Except that every GUI ever binds the menus to simple keystrokes. That way, "power users" can do things fast, while new users still have a chance to learn.

51

u/larhorse Apr 20 '15

so no on the example?

I mean, don't get me wrong, I absolutely understand the point about having an editor that I can use on a headless server pretty much anywhere, and I put up with vim during day to day use because of that. (cause really, VIM is better than nano at least)

That said, I vastly prefer pretty much anything else for actual coding. Sublime, Atom, TextMate, hell even Notepad++ if I happen to be stuck on windows (although NEVER notepad).

I even caved two years or so ago, and spent 6 months using nothing but vim to see if it changed my feelings about it. I really wanted to feel like I was being more productive, but in all measures, I wasn't. Turns out the mouse is REALLY damn good at doing things like selectively targeting text and precisely moving selections. It's almost like it was designed for that task. Plus it means I don't have to keep hundreds of esoteric key commands in my head!

0

u/[deleted] Apr 20 '15

[deleted]

→ More replies (2)

18

u/noop__ Apr 20 '15 edited Apr 20 '15

90% of my editing (4-12 hrs/day depending on the day), is done through an ssh session, so gui editing isn't really even a valid comparison. But that's just my use case. Obviously if another tool works better for you, you should use it.

and spent 6 months using nothing but vim to see if it changed my feelings about it

That is not nearly enough time to learn vim. I learn new stuff about it (and it makes me better) every week, and I've been using vim as my exclusive editor (aside from when I'm giving new stuff a shot) for the last decade.

12

u/muffsponge Apr 20 '15

So, if spend more than 6 months learning vim, will I ever make up that time in productivity? I feel comfortable using mouse in an IDE with intelligent autocomplete to get things done quickly. I just can't seem warrant the extra time to learn and remember all these commands.

17

u/noop__ Apr 20 '15

I just can't seem warrant the extra time to learn and remember all these commands.

Then don't :). Nobody is saying you have to use vim. At the end of the day, it doesn't matter what tools you use, it matters how well you do your job. If you think you're at your best using a gui editor, totally do it.

17

u/Mavamaarten Apr 20 '15

Nobody is saying you have to use vim

Uhhhh... I have never talked to a vim user without him telling me I should use vim.

15

u/Sean1708 Apr 20 '15

Oh? Well now you've talked to several.

9

u/WallyMetropolis Apr 20 '15

Wait, uh, aren't you doing that right now?

3

u/[deleted] Apr 20 '15

You probably just don't know that most vim users are vim users cause they don't tell you to use it.

6

u/[deleted] Apr 20 '15 edited Jul 13 '23

Removed: RIP Apollo

→ More replies (2)

0

u/[deleted] Apr 20 '15

[deleted]

→ More replies (5)
→ More replies (1)

4

u/DrHenryPym Apr 20 '15

Small example:

  1. Use * on a word, and it will search for that word.

  2. Use ce to change the highlighted word.

  3. Use n to find the next word.

  4. Use . to repeat the last change.

  5. Repeat steps 3 and 4. (Only two keyboard presses)

Or:

  1. :%s/<Ctrl-r> //new_word/g

<Ctrl-r> / will access the register used for searching.

<Ctrl-r> " will access the last copied or deleted text. Use p to paste it wherever.

<Ctrl-r> + will access clipboard.

I know that most editors can do all this very simply, but the fact that it only takes a few keypresses to quickly automate some editing goes a long way.

→ More replies (2)

6

u/scragar Apr 20 '15

I have 1 big argument, 54 buffers/clipboards(a-z, A-Z, * is your normal clipboard and there's the standard buffer it will use if none is specified), combine with a similar number of bookmarks(52 in total, a-z are unique per file, while A-Z are unique across the whole profile and will open the file the bookmark was last placed in if you jump to it) makes it insanely powerful.

Yes, it takes a great deal of getting used to, but it's hard to question how handy it is(I mean given the improvements of win7/8 it's now almost as good as a Linux distro, but I still really miss 2 clipboards/buffers at work).

→ More replies (1)

9

u/j201 Apr 20 '15

If you search 'vim screencasts', you'll find a bunch. This is a cool one: http://blog.extracheese.org/2010/11/screencast-custom-vim-refactorings.html

→ More replies (2)

4

u/astrellon3 Apr 20 '15

Best examples I can give you is the ability to modify the entire contents within a set of brackets or quotes. eg:

string url = "http://..... long url ...";

My cursor can be anywhere on that line (including before the start of the string) and I can type

ci"

Can that will take me to the first set of double quotes if in not within one already and delete the contents. The same applies to {}s, ()s, []s and XML tags (they are treated slightly differently) which means you can take the contents of a huge function or for loop and stick it somewhere else. Now this isn't something I do often, usually I'm changing something in a string or a function call or a function signature. It's nice to have the ability to change these things and move them around regardless of their size.

This is just one example, but it's usually the thing I miss the most when using other text editors.

3

u/gellis12 Apr 20 '15

Also, :s/phrase 1/phrase 2/ will replace any instance of phrase 1 with phrase 2 in your document. You can also press V to select whole lines of text, then type :s/^/#/ to put a # at the beginning of each selected line.

3

u/Dooey Apr 21 '15

I'm pretty sure even Notepad has find and replace.

Most editors also let you comment out lines with a couple keys. In Sublime Text, it's Cmd+/, and it auto-detects what syntax you are using, and what a comment is in that syntax.

→ More replies (3)
→ More replies (2)
→ More replies (42)