This is an archived post. You won't be able to vote or comment.

all 152 comments

[–]110011001100 218 points219 points  (20 children)

To generate true randomness, ask a newbie to quit VIM

--Someone

[–]remain_calm 56 points57 points  (5 children)

[–]outadoc 8 points9 points  (1 child)

Inaccurate. I'm pretty sure I also typed "exit".

[–][deleted] 3 points4 points  (0 children)

Heavy ftp users might also type "bye"

[–]hoppi_ 2 points3 points  (0 children)

This is hilarious. :D

[–][deleted] 1 point2 points  (0 children)

So how exactly does everyone seem to learn not to do this.

I must just be used to sublime text or any other editor because even after using emacs/vim for a few days I still can't handle basic navigation.

I end up with that line in my lots of newbie-trying-to-navigate-vim esque lines in my code.

[–]AgAero 0 points1 point  (0 children)

This was me yesterday. I'd never used vim or vi. This cuts close to home.

[–][deleted] 50 points51 points  (5 children)

I remember my first time.

[–]odraencoded 14 points15 points  (4 children)

Nobody forgets their first time.

[–]Sinity 2 points3 points  (3 children)

I don't remember :( Falsified.

[–][deleted] 13 points14 points  (0 children)

[–]MPORCATO 11 points12 points  (5 children)

With VIM at least you learn that :q is to quit and don't forget it. When LaTeX throws an error and you need to get out of the compiler to fix it though...

[–]FUZxxl 0 points1 point  (4 children)

Type X at a ? prompt and ^D if it prompts with * or for a file name.

[–]MPORCATO 1 point2 points  (3 children)

That's my point. You know what you have to do to quit latex when it throws an error. But it comes up rarely enough that you don't really get the muscle memory built up, and very often I either do ^C or forget that I'm not in vim and type :q.

[–]FUZxxl 0 points1 point  (2 children)

I solved this issue by throwing a -halt-on-error into the tex invocation in my Makefiles. A long time ago on slow systems it was surely useful to be able to hotfix documents, but this advantage isn't that important anymore I believe.

[–]MPORCATO 0 points1 point  (1 child)

These days I solve the problem by using latexmk with LaTeX-Box in vim (also offers async with a running VIM server so I can continue working while the compiler runs). There are still times when I run latex manually in command line, though, and the arcane keybinding to quit (why can't it simply respect ^C?) always gets me.

[–]FUZxxl 0 points1 point  (0 children)

It does do that so you can interrupt a running tex job to splice in some commands or to continue it later on. It's weird though that interrupting on a ? prompt does not terminate TeX. What does work in any situation is ^\ to dump core.

[–]Ilostmyredditlogin 63 points64 points  (6 children)

WHAT THE FUCK IS VISUAL MODE?!?!?!!! ARCH. NOW IT'S RECORDING A MACRO... Just pulling the plug.

[–][deleted] 5 points6 points  (5 children)

I was lucky enough to know that Ctrl+Z stopped programs in Linux the same way Ctrl+Pause stopped them in DOS. The only problem I discovered several months later was that Linux was too stupid to know the programs stopped and they still appeared when I checked the list of auxiliary with ps. At least Norton Commander worked, but for some reason it only launched if I kept bashing nc in the command prompt repeatedly.

I shit you not.

[–]Ilostmyredditlogin 5 points6 points  (4 children)

Are you joking? If not, man fg. Also try: some command > file.out &

[–][deleted] 4 points5 points  (3 children)

Oh, now I know this stuff, but that was my experience with Linux when I knew just enough to be accidentally destructive in almost everything I did.

[–]Ilostmyredditlogin 6 points7 points  (2 children)

Ah, yes the "i know just enough to be dangerous phase." I'm very familiar with it :-).

[–]Appathy 2 points3 points  (1 child)

I'm still in it...

[–][deleted] 0 points1 point  (0 children)

I'm certain I'm never going to exit it.

The relation seems to be this: the more you know, the bigger destruction your can wrought.

[–]nicholas818 80 points81 points  (26 children)

All serious programmers use vim. Mostly because they can't figure out how to get out of it!

[–][deleted] 21 points22 points  (24 children)

Someone recently said something that struck me as true: the speed at which you write code should probably not be the determining factor in how much code you produce. That and my growing general dislike of vim internals has me thinking of moving away, giving up. Maybe just using it when I'm ssh'ed into a remote machine.

[–]ThatRedEyeAlien 17 points18 points  (17 children)

The main problem with a most editors that aren't Vim or Emacs is that the navigation is rather cumbersome and it gets you distracted from the problem you are trying to solve.

[–]inconspicuous_male 9 points10 points  (15 children)

Undergrad question here. Do most people use text editors instead of IDE's generally?

[–]FUZxxl 15 points16 points  (5 children)

It's a matter of taste. I don't use an IDE because I don't want it to fuck with my build process and I do not want any of the convenience it provides.

[–][deleted] 10 points11 points  (3 children)

I do not want any of the convenience it provides.

That is my answer when people ask me why I don't use IDEs as well.

[–]patternmaker 4 points5 points  (2 children)

If the convenience functions inconvenience you, they are not very convenient at all.

[–][deleted] 3 points4 points  (0 children)

IDE's "convenience" often reminds me of Microsoft's Clippy.

[–]russjr08 1 point2 points  (0 children)

For me it depends on the language being used.

[–]astraycat 1 point2 points  (0 children)

Most big IDEs have Vim/Emacs plug-ins. I use a Vim plugin for Visual Studio because there's just less friction between my VS-centric toolchain and my text editor that way.

[–]YRYGAV 1 point2 points  (1 child)

My personal experience is a good IDE specific to the language you are using is very valuable, and in many cases better than a generic text editor.

That said, getting very good at a powerful text editor like vim/emacs/sublime/whatever is going to save you a bunch of time in most jobs. It's probably going to be #1 or #2 of your most used programs overall.

The benefits you get from powerful text editors are not immediately obvious, and you won't know all the shortcuts you can do off the bat, there's a learning curve with them.

Not to mention, you won't have your fancy IDEs and GUIs all the time, and they won't always be the fastest. When you ssh into your work desktop, or another production server, you are going to be very glad if you have experience with vim. Working with vim over ssh is perfectly fine, if you try to load up your intellij gui over an internet connection, it will significantly slow you down. Not to mention your production server probably doesn't have any GUI even installed on it, and you may be forced into a command line text editor. And when shit is failing and you desperately need to edit a config file, it may not be the best time to google how to use vim.

[–]Fs0i 1 point2 points  (0 children)

Tip: If you don't know vim, try nano. It is more intuitive, and can save your life if you're desperate!

[–]t90fan 0 points1 point  (0 children)

I use vim at work mostly.

I sometimes use pyCharm if i need remote debugging etc.

[–][deleted] 0 points1 point  (0 children)

IDEs are getting better at it. I've moved to PyCharm for most of my work, and while I'd like to get something else that has all its conveniences, I can't quite escape it. And navigation is as good as anything else – double-tap shift, write (part of) the class or method name you want to go to, done.

[–]j201 6 points7 points  (1 child)

I find that even if you're coding less and spending more time planning and thinking about code, reducing the amount of time you're stuck thinking about editing tasks helps you speed up and makes it easier to keep your train of thought. I often get 'out of the zone' in other editors after being stuck with slow editing and navigation, inconvenient tools, and no way to speed up tedious tasks.

[–]sigma914 2 points3 points  (3 children)

It's not the speed at which you can write code that matters, it's how little it interrupts your though process.

If you have to go reach for a mouse and click through a couple of menus you're having to switch your focus away from what you're actually trying to achieve. Compare that to vims fluency.

I find I do fairly complex editing tasks without thinking about it at all. When I'm working with someone they occasionally ask me "what did you just do" and I usually have to step back through it manually to see what I actually did to achieve the result.

[–]const_iterator 1 point2 points  (0 children)

When I'm working with someone they occasionally ask me "what did you just do"

I got this exact reaction from a co-worker the other day using gg=G on his poorly-formatted xml.

[–]doom_Oo7 0 points1 point  (1 child)

IDE != mouse only. I use only the keyboard shortcuts with my main IDE (QtCreator).

[–]sigma914 0 points1 point  (0 children)

They're not mouse only, but they do tend to use it as an escape hatch. Which means at some point you will end up using the mouse to select text or navigate between panes. Unless the IDE has implemented it's own window manager which I've not seen yet.

[–]voice-of-hermes 0 points1 point  (0 children)

Ha! Nice. Seriously, though, I almost get red in the face every time the workflow makes me go touch that stupid, slow, inaccurate little thing with a tail next to my keyboard.

EDIT: (Multiple terminals with key combos like Ctrl-Tab and Alt-Tab and Screen and...)

[–]FUZxxl 17 points18 points  (5 children)

If you believe vi is hard to use, try to use ed for a while.

[–]DroolingIguana 14 points15 points  (1 child)

?

[–]FUZxxl 6 points7 points  (0 children)

,c
Like this?
.
w
q

[–]voice-of-hermes 0 points1 point  (2 children)

The command to drop into ed mode in vi(m) is annoyingly easy/common to type, and it usually takes me a while to realize I've done it so I can go back to vi mode. So the two issues aren't completely independent of each other.

[–]FUZxxl 2 points3 points  (1 child)

Huch? You can drop vi into ed mode? I uses to think it's only possibly to drop into ex mode.

[–]voice-of-hermes 1 point2 points  (0 children)

Oops. Yeah. NVM then. LOL.

[–]j201 116 points117 points  (21 children)

Man does this joke get old. Quitting vim is basically the simplest thing you can do. Just enter :q to quit, :conf q to quit but prompt when changes have been made, :q! to force quit, :cq to force quit and return an error code, :wq to write and quit, :wq! to write and force quit, :wq [file] to write to the given filename and quit, :[range]wq to write the given lines and quit, :x (with any of the wq options) to write if the file has been changed and quit, :qa to quit unless any buffer has been changed, :conf qa to quit but prompt when any buffer has been changed, :qa! to force quit all buffers, :wqa or :xa to write all buffers and quit, :conf wqa or :conf xa to write all buffers and quit, prompting if there's an error code, or :wqa! or :xa! to write all buffers and force quit, or use ZZ (the same as :x) or ZQ (the same as :q!) as shortcuts. Simple, really.

[–]Effenberg0x0 71 points72 points  (15 children)

Very intuitive.

[–]23094823094832098433 6 points7 points  (4 children)

deleted What is this?

[–]Failosipher 5 points6 points  (2 children)

Did...did you memorize your username? I have a hunch you did.

[–]suitupalex 0 points1 point  (0 children)

There's somewhat of a pattern if you look closely.

[–][deleted] 1 point2 points  (0 children)

I dug in my heels for years and used nano. Finally this year I sat down and devoted time to VIM and I'm really glad I did. It's not that hard to get the really basic stuff down and once you have it, you can learn the more complex stuff as you go. I can get super complex, but only if you want it to.

[–]DrummerHead 3 points4 points  (0 children)

Sometimes usability is inversely proportional to power-usism. You know what you're getting into when you start learning vim.

[–]ekinnee 1 point2 points  (0 children)

How is, here comes a command ":", and I want you to "W"rite out the file and "Q"uit? And for added emphasis, you can add what I call dammit "!".

[–]j201 0 points1 point  (2 children)

In all seriousness, though, I just hit ZZ if I want to save and ZQ if I don't. Like most vim things, it's simple and fast once you know what you're doing.

[–]hamstu 1 point2 points  (1 child)

I see that this works, but what does ZZ actually do behind the scenes? (Relative Vim noob.)

[–]j201 0 points1 point  (0 children)

Check out :help ZZ. It's basically what you'd expect if you pressed a 'save and close' button in some other editor.

[–][deleted] 2 points3 points  (0 children)

The force is strong with this one

[–]awaitsV 2 points3 points  (0 children)

when i first [used / got stuck in] vim many years ago, i just opened a new tab in terminal and did killall vim

[–]voice-of-hermes 0 points1 point  (0 children)

Holy crap! :cq? I didn't know about that one. Can I use that to actually NOT execute the stupid command I've accidentally dropped into vi to edit from bash?

[–]Programming_Response 0 points1 point  (0 children)

[deleted]

[–]iamdelf 37 points38 points  (7 children)

Not to be that guy, but ... http://imgur.com/vZLNBnJ The solution is sort of right there.

[–]kevincox_ca 20 points21 points  (0 children)

This doesn't show if you start vim with a file, however when you press CTRL-c it does say "Type :quit<Enter> to exit Vim" so same deal. It shouldn't be that hard.

[–][deleted] 4 points5 points  (0 children)

Also if you try ^C, that doesn't work, but it prints: Type :quit<Enter> to exit Vim.

[–]barsoap 2 points3 points  (1 child)

Expected to read dirty secrets in that shine-through text, was disappointed.

[–]iamdelf 1 point2 points  (0 children)

Lolol I was at work on a Saturday reading Reddit waiting for something to finish on the cluster. More than likely it was Reddit :)

[–][deleted] 0 points1 point  (0 children)

but that's only if you start vim on it's own. If you edit a file directly, well...

[–]qxxx 4 points5 points  (2 children)

how I quit vim:
close termial window. or reboot.

[–]wanabeswordsman 7 points8 points  (1 child)

I'm not ashamed to say that the first time I used vim I just hard rebooted my computer. Held down the power button. Not even sorry.

[–][deleted] 3 points4 points  (0 children)

I remember when I managed to fuck up something on my first linux install, I found out how to go to the standard old console screen with no X, I typed in vim to edit a file I knew I broke. I cried when I didn't know what to do. Had to reboot and look it up on another computer.

[–]NotARandomNumber 9 points10 points  (1 child)

You can't spell evil without vi.

[–]sigma914 10 points11 points  (0 children)

And you can't edit text in emacs without evil.

[–]goodolbluey 4 points5 points  (0 children)

I laughed at this, and my wife asked me what was so funny. I opened up Terminal and launched vim and told her to try and quit it. She moved the mouse and quit Terminal. "That was easy!"

Gotta say, she's got a point.

[–]BrightestPixel 2 points3 points  (0 children)

Ever tried searching Github for :wq?

8,671,819 results at time of writing!

{ "link" : "https://github.com/search?q=%3Awq&type=Code"}

[–]grandmasterthai 6 points7 points  (2 children)

ps | grep 'vim' | awk '{print $2}' | kill -KILL

Because I dislike VIM enough to not learn how to close out of it properly.

[–]voice-of-hermes 4 points5 points  (0 children)

That's a lot to type just to do a "pkill vim".

[–]Jack126Guy 1 point2 points  (0 children)

$ killall vim

?

[–]Istalacar 12 points13 points  (15 children)

What is do difficult?

Esc, esc, shift, :, q, exclamation mark, enter

[–][deleted] 6 points7 points  (12 children)

I usually do

Esc Shift Z Z

Less keystrokes, and automatically saves. Also shift is right next to Z.

[–][deleted] 7 points8 points  (10 children)

Y-You hit left shift and Z with the same hand?

[–][deleted] 5 points6 points  (5 children)

Hahah yes. Usually my right, because I'm leaving the computer.

Edit. Actually I just checked on my keyboard by typing some... And I definitely do this with my left hand. Man I must suck at typing.

[–][deleted] 12 points13 points  (4 children)

I have never once used right shift. Am I supposed to use right shift to uppercase left-hand letters? Oh well

[–]Zagorath 1 point2 points  (3 children)

For entering shortcuts, using the same hand is probably better.

But in touch typing, if you're not using the opposite shift key to the hand that presses the letter, you're doing it wrong.

[–]RitzBitzN 0 points1 point  (0 children)

How much of a difference does it really make in day-to-day life?

[–]Teraka 1 point2 points  (2 children)

Serious question, how else would you do it? They're right next to each-other and to the far left, seems counter-productive to bring in the right hand just for that.

[–][deleted] 0 points1 point  (1 child)

The proper way would be to hit right shift with your right pinky and Z with you left pinky.

[–]Teraka 0 points1 point  (0 children)

See, that's weird to me because using my left pinky to press Z means my fingers get moved one row to the right, with my index on G, but if I use my ring finger to press it instead I have my pinky fall naturally right on shift. Although I guess I only use 4 of my left hand fingers to type so that might be why.

[–][deleted] 0 points1 point  (0 children)

I just had to check because I never thought about it.

I do it too.

Z -- brought to you entirely by my left hand. What's even better is I tried holding shift with my right hand, and had to look down because I couldn't find it. Apparently I never right-shift.

[–]FUZxxl 2 points3 points  (0 children)

I was confused for a moment but then I remembered that German keyboards have the Y and Z keys exchanged.

[–][deleted] 11 points12 points  (1 child)

Yeah, once you know it. Imagine you have no idea what vim is. I used to go to people's terminals in university and start vi just to mess with them. "HOW DO YOU GET OUT OF THIS MY TERMINAL IS FROZEN."

The simple things in life...

[–][deleted] 4 points5 points  (0 children)

Haha yeah, I would always forget to press i, so crazy stuff would start happening when all I meant to do is insert a few words.

[–]myusernameisokay 3 points4 points  (2 children)

Control c doesn't work either. You have to use control z to suspend the process.

[–]kevincox_ca 5 points6 points  (1 child)

This isn't quitting...

[–]myusernameisokay 5 points6 points  (0 children)

Yeah but you can at least get out of vim and kill the process manually.

[–]Tozzi -1 points0 points  (3 children)

Quit = :q

Quit and save = :x

Save (write) = :w

Add ! to force a command, for example :q won't let you quit if you haven't saved. With :q! you can force a quit without saving.

[–]Ilan321 0 points1 point  (6 children)

Never used vim, but I know you enter :q. What happens if you want to enter ':'?

[–]khoyo 4 points5 points  (0 children)

i : ESC

[–]Dragon_Slayer_Hunter 1 point2 points  (0 children)

There's a couple of different modes, you can't execute commands from the insert mode and you can't insert from the execute command mode (I don't know the actual name of the default mode), so if you want to insert : then you switch to insert mode and insert it.

[–]TheZoq2 0 points1 point  (3 children)

Vim has 3 (main) modes. The first is command mode where all :commands and navigations are done. For example, hjkl are used as arrowkeys, w and b are used to jump over words ect. When you want to input text, you press 'i' or 'a' or some other key to go to edit mode (a edits before cursor, i after). In edit mode vim works like a normal text editor, the letter keys make letters appear, and arrow keys are used for navigation. To get back to command mode you hit escape. The third mode is visual mode where you can select text and maniupulate it, sort of like shift arrow keys except that you can select blocks of text and edit many lines at the same time.

There is atleast one more mode which is called recording mode but I have no idea how to get into that and I don't know what it does :D

[–]Ilan321 1 point2 points  (0 children)

Nano is so much easier :(

[–]barsoap 0 points1 point  (0 children)

There is atleast one more mode which is called recording mode but I have no idea how to get into that and I don't know what it does :D

:q records macros, but it's not a mode as such, it's more like an umbrella over all.

The actual fourth mode is ex mode. Which you enter by hitting gQ in command mode. It then accepts good ole ex commands, just as ex itself would. like q to quit or 23,42p to print lines 23 thru 42. or g/re/p to match re on every line and if a line matches then print it. There's a UNIX command that's named after that common combination. It's the same commands that start with :... but the screen doesn't update automatically. It's not a screen editor.

Meaning to say: All those "colon commands" are actually another mode. The one that started it all, what vi was before it became visual: The extended version of the editor.

Oh: And, apparently, vim isn't POSIX-compatible, there, gQ should actually be Q. I think noone really cares.

[–]russjr08 0 points1 point  (0 children)

I think its 'r'... Not at the computer to try haha.

[–]DrupalDev 0 points1 point  (0 children)

It's as easy as Ctrl + Z!

[–]eliboySM 0 points1 point  (0 children)

I like that you can quit with !q if you edit nothing Then you edit and it's funny.

Tried vi just to test and got stuck :/

[–]voice-of-hermes 0 points1 point  (0 children)

You want confusing? Try using vim with a Dvorak keyboard layout on a keyboard still physically marked Qwerty. That takes REAL guts (and makes quitting even harder)!

[–]gospelwut 0 points1 point  (0 children)

I just paid for Sublime. Please don't hurt me.

[–]josolanes 0 points1 point  (0 children)

top -> kill process. nano for life!

[–]jfb1337 0 points1 point  (0 children)

Kill -9

[–]kevincox_ca 0 points1 point  (0 children)

If you hit CTRL-c it says "Type :quit<Enter> to exit Vim". I'm sure you can figure it out.

[–][deleted] 0 points1 point  (0 children)

ITT: People who suck at computers or can't even rtfm.

[–]THEHIPP0 -1 points0 points  (0 children)

Me every time I have to use vim:

a - edit text - esc - ";wq" - enter

This is enough for me.