r/programming • • Apr 01 '19

Stack Overflow ~ Helping One Million Developers Exit Vim πŸ˜‚

https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/
2.5k Upvotes

441 comments sorted by

View all comments

183

u/KapteinTordenflesk Apr 01 '19

I tried VIM probably 10 years ago, and trying to exit is literally the only thing I remember from the experience.

22

u/chaxor Apr 01 '19

The worst problem I have with vim is copy/pasting to other programs, such as a browser for stackoverflow.

While I appreciate vim's complexity and use it fairly consistently along other editors at work - this fairly major functionality deficit (and other similar small annoyances) are what keep me from using *only* vim.

I know there are ways to do essentially anything in vim - but this is also likely true for any editor, so it's somewhat a null point. The autocomplete issue that many people have brought up here is a valid one, as it is simply one more step to perform to bring vim to the customized editor you desire.

The fact that copy/pasting requires a specific type of vim to be installed, as well as a 1600 word explanation of registers is a bit a of a nuisance. (1,2)

  1. https://stackoverflow.com/questions/3997078/how-to-paste-yanked-text-into-vim-command-line

  2. https://askubuntu.com/questions/60200/how-to-copy-data-between-different-instances-of-vim

Somehow, it's still a great editor and I use it quite often.

9

u/watsreddit Apr 02 '19 edited Apr 02 '19

set clipboard=unnamedplus

That's literally all it takes to make vim use the system clipboard by default. Of course none of us really do, because the defaults are quite useful. I certainly don't want copying some URL in my general web browsing to mess up my registers in vim, save for the registers dedicated specifically for that purpose. Nor do I want basically every vim command to be overwriting the system clipboard all the time. Copy/paste is much more integral to vim than other editors (except for perhaps Emacs), so it makes sense to separate vim's standard copy/paste from system copy/paste.

→ More replies (6)

118

u/rageingnonsense Apr 01 '19

I can sum up my vim usage in 4 commands:

  • :q

  • :w

  • a

  • /

That's it. That's as much as I am willing to learn. If I need anything more powerful than that, it's straight to the ide

75

u/[deleted] Apr 01 '19

[removed] β€” view removed comment

48

u/carterja Apr 01 '19

i is important.. o is pretty damn handy as well.

16

u/ring2ding Apr 01 '19

What's o?

52

u/e_man604 Apr 01 '19

Insert a blank line underneath the current line and toggle insert mode. Capital O is above the current line.

21

u/Bobshayd Apr 01 '19

J is the inverse - puts the next line on the end of the current line.

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

14

u/lordheart Apr 01 '19

Also dd Deleted current line

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

9

u/phire Apr 01 '19

Don't you mean a, left-arrow?

8

u/TommaClock Apr 01 '19

Also no d ?

33

u/caltheon Apr 01 '19

i use dd more than d

29

u/thirdegree Apr 01 '19

For me it's either dd or dsome obscenely intricate movement that really should probably be a macro and will definitely go wrong

→ More replies (16)
→ More replies (3)
→ More replies (1)
→ More replies (8)

0

u/[deleted] Apr 01 '19

[deleted]

36

u/NovaX81 Apr 01 '19

:q!, for when you want to make absolutely sure you didn't fuck with it.

→ More replies (1)

19

u/W0rldcrafter Apr 01 '19

:x or ZZ are also shorthand for :wq

15

u/ChocolateBunny Apr 01 '19

TIL about :x. I've used VIM for 15 years and have never done :x.

5

u/King_Joffreys_Tits Apr 02 '19

I know :x is a thing but I don’t trust it. :wq all day

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

5

u/[deleted] Apr 01 '19

I’d at least recommend learning macros. Also:

  • w

  • b

  • G

  • gg

  • <num>G

βŠ• the different modes. Visual mode for example.

→ More replies (2)
→ More replies (82)

8

u/rabidstoat Apr 01 '19

I am diehard VIM but sometimes I get thrown in emacs, which is the default editor in one of my bash accounts. Like if I'm trying to 'svn commit' and forgot to do the comments on the command line.

The only thing I know how to do in emacs is 'C-x C-c'.

→ More replies (2)

15

u/OneWingedShark Apr 01 '19

I tried VIM probably 10 years ago, and trying to exit is literally the only thing I remember from the experience.

Exiting VIM: unplug computer.

NOTE: This solution does not work with computers using magnetic-core memory or other persistent-state mechanisms.

17

u/Nyefan Apr 01 '19 edited Apr 01 '19

Won't lie, that's how I exited vim the first time years ago.

I led with ctrl+c, as you would expect, and saw the message Type :qa! and press <Enter>.... You'd think it would be straightforward from there, but I had a very unique experience - for the last 3 months, I had been using Mathematica for work. Now, anyone who uses Mathematica can see where this is going, I'm sure. You see, Mathematica uses a colon-like symbol to delineate commands from variables and operators, and I was just diving into the worlds of linux and programming for the first time, so that was the only context I had to work with. "What's wrong here?" you ask. Here's the link - you insert the delineator in Mathematica by pressing ESC.

So I follow the instructions on the screen - I type <ESC>qa! and am presented with the message recording @a. Well shit. Ctrl+c still doesn't work, pressing <ESC>qa! again types a ! into the sudoers file and says I'm on -- INSERT -- this time. I try looking it up on my phone, and everything says to type :q!, which clearly isn't working. Oh, and I was installing arch and didn't have a ui yet (I couldn't close the terminal), so I turned it off and started the install process again after looking up how to force the terminal editor to be nano by default and bypassing visudo in favor of directly editing the sudoers file.

→ More replies (6)
→ More replies (1)
→ More replies (15)