What Programmers Say vs. What They Mean

๐ŸŽ™๏ธ TW80000 ยท 3592 points ยท Posted at 19:40:00 on June 1, 2014 ยท (Permalink)


peter_bolton ยท 115 points ยท Posted at 21:41:25 on June 1, 2014 ยท (Permalink)

And, more often than not, a "temporary workaround" is actually more of a permanent one.

Tynach ยท 105 points ยท Posted at 23:32:32 on June 1, 2014 ยท (Permalink)
  • Temporary Workaround:
    Horrible hack that I wrote and refuse to fix.
mahacctissoawsum ยท 43 points ยท Posted at 23:50:47 on June 1, 2014 ยท (Permalink)

I don't think many of us would actively refuse to re-write a shitty piece of code...it's just that time/budgets don't allow for it.

Tynach ยท 15 points ยท Posted at 01:45:43 on June 2, 2014 ยท (Permalink)

Sure, but there are those few who vehemently swear by their code, and even if they admit it has a problem, they don't want ANYONE touching it except them.

mahacctissoawsum ยท 23 points ยท Posted at 02:11:00 on June 2, 2014 ยท (Permalink)

True....I don't want anyone touching my code. Last time someone tried "optimizing" my code they created a swath of bugs which of course later got tossed back to me because I wrote the original code. Been fighting that shit for years now.

Tynach ยท 10 points ยท Posted at 02:30:24 on June 2, 2014 ยท (Permalink)

Exactly. And some people refuse to admit it's their code causing the problem, and blame it on others. *wink wink*

But yeah. Often we're rather knowlegable in our own code, and have reasons for it being the way it is. We may have tried it using other ways at first, and it's very natural to want to handle it yourself because you don't want other people to bother trying all the other ways and ending up exactly where they started at the end of it.

And it can be really hard to tell who's being thick headed, and who's simply the most knowledgeable about that area of code.

Cyberogue ยท 22 points ยท Posted at 04:23:11 on June 2, 2014 ยท (Permalink)
//TODO: THIS IS TEMPORARY

.... 100 commits later

Creag ยท 12 points ยท Posted at 03:01:50 on June 2, 2014 ยท (Permalink)

If you say Temp workaround to management all they hear is "It works, so why would I give your project more money to fix something that works?"

Tynach ยท 2 points ยท Posted at 03:05:41 on June 2, 2014 ยท (Permalink)
xkcd_transcriber ยท 4 points ยท Posted at 03:06:23 on June 2, 2014 ยท (Permalink)

Image

Title: Interview

Title-text: Hey, before you go, can you explain to me what job I now have?

Comic Explanation

Stats: This comic has been referenced 3 time(s), representing 0.0136% of referenced xkcds.


xkcd.com | xkcdย sub/kerfuffle | Problems/Bugs? | Statistics | Stopย Replying

Spivak ยท 1 points ยท Posted at 03:11:19 on June 2, 2014 ยท (Permalink)

Or in my specific case, there's a known bug in the library or tool I'm using and here's some code that emulates the correct behavior until the next release.

Tynach ยท 4 points ยท Posted at 03:15:53 on June 2, 2014 ยท (Permalink)

And then you leave the project, and when the next release comes out and breaks the workaround, it'll cause the programmer who inherited your work to become frustrated because he can't upgrade to the new version of the library.

Amirite?

codnahfish ยท 1 points ยท Posted at 17:52:31 on June 13, 2014 ยท (Permalink)

I had something like that happen to me except I was the person before and after the real fix.

This was using a WordPress plugin that displayed shit incorrectly on one of their "updates". I managed to fix it then the next update fixed that bug and all was well.

Except, all was not well. It wasn't noticed until a few weeks later that we couldn't edit or delete anything, or update plugins. The client was frustrated that I couldn't fix this issue (even though I had no error messages at all, with all debug settings turned on).

Eventually I did something, I don't know what, but plugins were able to be updated. Funnily enough there was an update to one of the plugins and that update fixed everything. Client was happy.

TL;DR; I did a temporary fix that was later patched but that patch broke other shit. Another patch fixed all the shit.

Tynach ยท 1 points ยท Posted at 17:59:47 on June 13, 2014 ยท (Permalink)

Bit of an old post for you to respond to, but interesting little story nonetheless :)

codnahfish ยท 1 points ยท Posted at 20:02:59 on June 13, 2014 ยท (Permalink)

Yeah, I just went through pages and pages of this subreddit. I didn't realise how old it was until after I posted. :)

Tynach ยท 1 points ยท Posted at 22:21:13 on June 14, 2014 ยท (Permalink)

Haha. It happens :)

[deleted] ยท 22 points ยท Posted at 03:57:29 on June 2, 2014 ยท (Permalink)
//TODO: Fix this code (3/6/2005)
chasesan ยท 6 points ยท Posted at 10:20:20 on June 3, 2014 ยท (Permalink)
// TODO: Fix this code (19970424)
digitalpencil ยท 5 points ยท Posted at 12:00:22 on June 2, 2014 ยท (Permalink)
mrowa ยท 4 points ยท Posted at 02:08:42 on June 2, 2014 ยท (Permalink)

...until requirements change and temporary workaround stands in your way and your "2h and finished" task gets partial rework of workaround up to 12h and three tickets from testers...

Talran ยท 2 points ยท Posted at 04:49:42 on June 2, 2014 ยท (Permalink)

Temporary, in the meaning that the version that has that module rewritten later will supersede it.

๐ŸŽ™๏ธ TW80000 ยท 65 points ยท Posted at 19:41:26 on June 1, 2014 ยท (Permalink)
enahsh2o ยท 2 points ยท Posted at 22:04:32 on June 1, 2014 ยท (Permalink)

Yeah, I believe that is right. That was the first place I saw it at least.

OverZealousCreations ยท 331 points ยท Posted at 20:09:49 on June 1, 2014 ยท (Permalink)

Should be:

What we say What we mean
I can't read this Perl script I didn't write this Perl script
I can't read this Perl script I wrote this Perl script

:-)

Artemis2 ยท 434 points ยท Posted at 20:36:51 on June 1, 2014 ยท (Permalink)
What we say What we mean
I can't read this Perl script This script is written in Perl
[deleted] ยท 167 points ยท Posted at 20:39:12 on June 1, 2014 ยท (Permalink)*

[deleted]

FTFYcent ยท 77 points ยท Posted at 20:49:07 on June 1, 2014 ยท (Permalink)

Like not using Perl.

Tynach ยท 35 points ยท Posted at 23:26:32 on June 1, 2014 ยท (Permalink)

Yeah. It needs to be rewritten from scratch in x86 asm.

wave100 ยท 19 points ยท Posted at 03:29:47 on June 2, 2014 ยท (Permalink)

With a hard drive platter and a magnetized needle.

[deleted] ยท 5 points ยท Posted at 04:14:47 on June 2, 2014 ยท (Permalink)

Yeah. It needs to be rewritten from scratch in x86 asm.

oh, ehllo again! Did you get vimium?

wave100 ยท 3 points ยท Posted at 20:41:15 on June 2, 2014 ยท (Permalink)

Oh hey! Long time, no see! I've got a chrome profile set up for it, I use it when I want to reddit without anybody noticing. It's awesome!

shillbert ยท 2 points ยท Posted at 17:53:03 on June 2, 2014 ยท (Permalink)
post db "Yeah. It needs to be rewritten from scratch in x86 asm.",0

; how the hell do I print this on multiple platforms without including the C standard library?
RenaKunisaki ยท 2 points ยท Posted at 03:37:43 on June 3, 2014 ยท (Permalink)
int 21h
shillbert ยท 2 points ยท Posted at 03:54:37 on June 3, 2014 ยท (Permalink)

Yeah, try an int 21h on Windows 7 and let me know what happens.

RenaKunisaki ยท 3 points ยท Posted at 05:19:39 on June 3, 2014 ยท (Permalink)

Huh.

Hey, how do I report a bug in Windows?

shillbert ยท 2 points ยท Posted at 05:37:14 on June 3, 2014 ยท (Permalink)

Save your bug report to the root of the C drive as bugreport.txt, then run this command in the command prompt:

type c:\bugreport.txt > NUL

Your bug report will be looked at in about 4-6 decades.

gd2shoe ยท 67 points ยท Posted at 20:49:48 on June 1, 2014 ยท (Permalink)

"I wrote this perl script recently"

"Who wrote this?!?"

idiogeckmatic ยท 20 points ยท Posted at 21:46:34 on June 1, 2014 ยท (Permalink)

poor perl, it will always pay the price for terrors people wrote 10 years ago.

northrupthebandgeek ยท 36 points ยท Posted at 23:35:06 on June 1, 2014 ยท (Permalink)

And still write. There's something beautiful about a seemingly-random vomiting of punctuation marks actually doing something useful.

lx45803 ยท 30 points ยท Posted at 23:41:18 on June 1, 2014 ยท (Permalink)

There's also something beautiful about train wrecks. That doesn't make them a good thing.

mike413 ยท 35 points ยท Posted at 22:26:28 on June 1, 2014 ยท (Permalink)
What we say What we mean
I can read this Perl script I just looked at the Makefile
I love Perl I just looked at the Makefile
Perl is pretty readable I just looked at the Makefile
mike413 ยท 25 points ยท Posted at 22:31:21 on June 1, 2014 ยท (Permalink)

one more..

What we say What we mean
I don't even mind OO Perl I just looked at the Makefile, it's recursive
Tynach ยท 5 points ยท Posted at 23:28:53 on June 1, 2014 ยท (Permalink)

Why would Perl code require a Makefile?

[deleted] ยท 27 points ยท Posted at 01:49:22 on June 2, 2014 ยท (Permalink)

Because makefiles are so godawful, they make Perl code look readable.

three18ti ยท 9 points ยท Posted at 01:33:33 on June 2, 2014 ยท (Permalink)

Perl uses Makefiles to compile and install libraries. Perl uses XS which allows it to call C and C++ functions. Essentially, it allows us to use standard make toolchains to build/test (since the Perl community is largely TDD)/install.

I knew everyone is reading on Perl, that just goes to show it's still relevant. Sure, it's not en vogue like Ruby, or Go, or JavaScrip as a server... but we're still around.

Go checkout /r/perl

mike413 ยท 5 points ยท Posted at 06:09:00 on June 2, 2014 ยท (Permalink)

Actually, I wasn't talking about perl's Makefiles. I have many projects that include perl code, shell scripts, c/c++ code and Makefiles. By far, Makefiles are the hardest to maintain. As a matter of fact, I would say Makefiles with no abstractions whatsoever might be the easiest to work with. (of course, nobody does that).

Tynach ยท 3 points ยท Posted at 08:10:28 on June 2, 2014 ยท (Permalink)

I have very little experience with Makefiles. I always assumed there was some trick to it, but every time I tried to learn them they made my brain melt. So, I've stuck with CMake.

[deleted] ยท 4 points ยท Posted at 23:47:06 on June 1, 2014 ยท (Permalink)

The code might be so unreadable that you're afraid of running it without an extra layer of tools.

RenaKunisaki ยท 1 points ยท Posted at 23:53:21 on June 1, 2014 ยท (Permalink)

The makefile is a Perl script that generates the actual code.

adeadhead ยท 0 points ยท Posted at 03:28:22 on June 2, 2014 ยท (Permalink)

Bahahaha

Imxset21 ยท 14 points ยท Posted at 22:00:09 on June 1, 2014 ยท (Permalink)

Perl: There's more than one way to completely screw it up.

tigerstorms ยท 7 points ยท Posted at 22:44:29 on June 1, 2014 ยท (Permalink)

true story, Only worked with perl scripts twice, and head to re-learn it both times to get them to work.

[deleted] ยท 43 points ยท Posted at 20:43:01 on June 1, 2014 ยท (Permalink)

First one is recursive

ilyd667 ยท 14 points ยท Posted at 23:14:56 on June 1, 2014 ยท (Permalink)

How were you able to step out of it and write your comment when it's missing the base case?!

Tynach ยท 10 points ยท Posted at 23:30:25 on June 1, 2014 ยท (Permalink)

In the second one, we see a pointer. We can choose not to dereference that pointer.

Hondros ยท 6 points ยท Posted at 02:53:59 on June 2, 2014 ยท (Permalink)

He overflowed, simple.

iTotzke ยท 5 points ยท Posted at 15:54:19 on June 2, 2014 ยท (Permalink)
Cyberogue ยท 6 points ยท Posted at 04:24:53 on June 2, 2014 ยท (Permalink)

Horrible hack that I didn't write that I didn't write that I didn't write that I didn't write that I didn't write th[ERROR: MEMORY STACK OVERFLOW]

[deleted] ยท 412 points ยท Posted at 22:27:28 on June 1, 2014 ยท (Permalink)

I've been using Vim for about 2 years now, mostly because I can't figure out how to exit it.

anonymfus ยท 88 points ยท Posted at 22:50:22 on June 1, 2014 ยท (Permalink)
IrisBlaze ยท 10 points ยท Posted at 12:04:05 on June 2, 2014 ยท (Permalink)

O.o of course there's a subreddit for that

Modevs ยท 7 points ยท Posted at 20:29:46 on June 2, 2014 ยท (Permalink)
ilyd667 ยท 53 points ยท Posted at 23:16:43 on June 1, 2014 ยท (Permalink)

So yeah, this sentence really triggered some PTSD flashback of my first time with vim.

SanityInAnarchy ยท 4 points ยท Posted at 02:36:43 on June 2, 2014 ยท (Permalink)
mahacctissoawsum ยท 31 points ยท Posted at 23:49:53 on June 1, 2014 ยท (Permalink)

Every time some stupid program has Vim as the default editor.... I have to close the fucking terminal.

darkslide3000 ยท 34 points ยท Posted at 01:58:10 on June 2, 2014 ยท (Permalink)

Doesn't vim even helpfully tell you "type :q! to quit" when you press Ctrl+C or something like that these days?

ordona ยท 48 points ยท Posted at 02:47:15 on June 2, 2014 ยท (Permalink)

Vim does; vi doesn't. Vi just gives you:

:^C
Interrupt
:^C
Interrupt
:^C
Interrupt
:^C
Interrupt
:^C
Interrupt
:^C
Interrupt
:^C
Interrupt
:^C
Interrupt
:^C
Interrupt
:^C
Interrupt
:
[deleted] ยท 36 points ยท Posted at 03:00:32 on June 2, 2014 ยท (Permalink)

[deleted]

RenaKunisaki ยท 4 points ยท Posted at 03:38:46 on June 3, 2014 ยท (Permalink)

Good UI design? What's that?

Mistercheif ยท 36 points ยท Posted at 02:04:44 on June 2, 2014 ยท (Permalink)

Yes, it does.

While emacs kills your family and laughs over their corpses when you type :q

benzrf ยท 2 points ยท Posted at 02:03:47 on June 2, 2014 ยท (Permalink)

it does, I don't know what these people are talking about

Aluxh ยท 4 points ยท Posted at 07:24:13 on June 2, 2014 ยท (Permalink)

A lot of systems come with vi, not vim.

[deleted] ยท 1 points ยท Posted at 15:30:10 on June 2, 2014 ยท (Permalink)

But nearly all systems come with a package manager where installing vim is trivial.

Aluxh ยท 2 points ยท Posted at 15:31:47 on June 2, 2014 ยท (Permalink)

One of vi's biggest selling points is that it's available on so many distros by default. You can easily add emacs or nano too.

[deleted] ยท 2 points ยท Posted at 15:33:59 on June 2, 2014 ยท (Permalink)

I think that was a selling point at a time when you didn't expect ubiquitous networking. Not so sure it's a selling point today.

Aluxh ยท 4 points ยท Posted at 16:37:40 on June 2, 2014 ยท (Permalink)

It's still a selling point. What if you don't have root privileges? Are you gonna mess about with a work around or just use vi?

Just because it's not useful for you doesn't mean it's not useful.

shillbert ยท 1 points ยท Posted at 17:59:54 on June 2, 2014 ยท (Permalink)

If I don't have sudo privilege for the package manager, I'll write a very strongly worded letter to the sysadmin.

Bobshayd ยท 1 points ยท Posted at 18:55:27 on June 2, 2014 ยท (Permalink)

Or, you're trying to edit configuration files on the system, and you haven't configured it to do DNS resolution, or use the appropriate proxies for your company, and that's what you're using a text editor for in the first place.

You could probably just use nano, though, at that point.

Aluxh ยท 1 points ยท Posted at 10:23:47 on June 3, 2014 ยท (Permalink)

Indeed. I'd rather use nano anyway but I didn't wanna start that war ;P

podian ยท 1 points ยท Posted at 22:07:12 on October 21, 2014 ยท (Permalink)
three18ti ยท 24 points ยท Posted at 01:37:37 on June 2, 2014 ยท (Permalink)

SEE emacs IS better. ctrl + alt + mod + caps + [ESC] + pageup + "execute butterfly quit"

n1c0_ds ยท 4 points ยท Posted at 15:31:38 on June 2, 2014 ยท (Permalink)

Escacpe, then : and q, enter.

Euphi_ ยท 3 points ยท Posted at 00:49:22 on June 2, 2014 ยท (Permalink)

Oh good i'm not alone, i always feel like a failure when I have to close the window

wave100 ยท 1 points ยท Posted at 03:31:22 on June 2, 2014 ยท (Permalink)

I tried to write an essay in vim once...

NEVER. AGAIN.

[deleted] ยท 6 points ยท Posted at 04:15:54 on June 2, 2014 ยท (Permalink)

I do it all in vim... Vi! Vi! Vi!

wave100 ยท 2 points ยท Posted at 20:41:55 on June 2, 2014 ยท (Permalink)

Keep in mind, this was back when I was first getting into linux and had no idea how to quit. Most intense 30 seconds of my life.

[deleted] ยท 9 points ยท Posted at 01:02:29 on June 2, 2014 ยท (Permalink)

Whereas I used to use vi a lot because nano wasn't a thing yet and the exit sequence is now forever burned into my memory.

the8thbit ยท 6 points ยท Posted at 07:00:12 on June 2, 2014 ยท (Permalink)

Oh vim, why can't I quit you? <3

JSLEnterprises ยท 13 points ยท Posted at 02:56:07 on June 2, 2014 ยท (Permalink)

Best way to troll someone that actually knows how to use Vim, remap some of the keys that are frequently used commands.

kaiden333 ยท 13 points ยท Posted at 05:42:15 on June 2, 2014 ยท (Permalink)

Or run a script that remaps them only occasionally.

JSLEnterprises ยท 9 points ยท Posted at 07:06:28 on June 2, 2014 ยท (Permalink)

even better, i like the way you think. but a randomized algorithm, so the swaps are never the same.

eddbc ยท 14 points ยท Posted at 08:30:25 on June 2, 2014 ยท (Permalink)

I've always wanted to know, what is Satan really like? You are related, right?

JSLEnterprises ยท 12 points ยท Posted at 12:09:05 on June 2, 2014 ยท (Permalink)
tttttttttkid ยท 1 points ยท Posted at 12:45:14 on June 2, 2014 ยท (Permalink)

Just bash their keyboard and/or computer with a sledgehammer.

[deleted] ยท 4 points ยท Posted at 04:16:21 on June 2, 2014 ยท (Permalink)

give them a dvorak keyboard

jfb1337 ยท 6 points ยท Posted at 08:45:35 on June 2, 2014 ยท (Permalink)

Nah, just remap their qwerty keyboard to behave like a dvorak keyboard.

Earthborn92 ยท 2 points ยท Posted at 04:13:18 on June 2, 2014 ยท (Permalink)

You are an evil person.

Just thought you should know.

SupermanBerger ยท 1 points ยท Posted at 11:39:46 on June 14, 2014 ยท (Permalink)

You monster.

LoadInSubduedLight ยท 3 points ยท Posted at 14:52:42 on June 2, 2014 ยท (Permalink)

Every time I sneeze in front of my keyboard I end up in Vi.

I usually have to restart my computer to get out.

ctrl_all_del ยท 1 points ยท Posted at 06:58:32 on June 2, 2014 ยท (Permalink)

Esc :q! (I know you were joking)

dexbg ยท 4 points ยท Posted at 11:55:55 on June 2, 2014 ยท (Permalink)

:q!

He looks so sad :(

Kyyni ยท 88 points ยท Posted at 20:54:52 on June 1, 2014 ยท (Permalink)

If we go by these definitions, all code that is older than five minutes is legacy code that needs to be rewritten. That's a law of nature. Once the design is out of your mind and on the screen, it becomes a piece of dead ancient language with no hope of ever again understanding.

mahacctissoawsum ยท 70 points ยท Posted at 23:48:34 on June 1, 2014 ยท (Permalink)

C'mon now. The code is usually good until the requirements change. That gives us as much as 10 minutes.

Cyberogue ยท 25 points ยท Posted at 04:28:18 on June 2, 2014 ยท (Permalink)

"Hey boss, you're back from lunch early..."

"Yeah see I was thinking about the requirements and I wanted to make one tiny change to $feature_worked_on_a_week_ago..."

Glitter_puke ยท 31 points ยท Posted at 00:33:55 on June 2, 2014 ยท (Permalink)*

Most of my comments are asinine snark directed at my future self. So I never have any clue what's going on. I shouldn't code drunk, but it just flows so much better.

//haha good fucking luck reverse engineering this, asshole.

Stuff like that.

Goofybud16 ยท 17 points ยท Posted at 02:51:04 on June 2, 2014 ยท (Permalink)
//haha good fucking luck with all the recursive methods on AP tests, asshole

Seriously though, Recursive methods in java are just terrible. They are slow, hard to debug, and just bad.

public void fuckYou(int i)
{
    if(i > 1000)
    {
       fuckYou((i / 2) % 3); 
    }
}

How many times would fuckYou(23456337) run?

LeepySham ยท 37 points ยท Posted at 03:19:45 on June 2, 2014 ยท (Permalink)

Well once when you first call it, then one recursive call, right? Because %3 always gives 0, 1, or 2, which are all less than 1000.

jfb1337 ยท 4 points ยท Posted at 08:54:04 on June 2, 2014 ยท (Permalink)

Once, when you call it? % 3 will always be less than 1000.

Darksonn ยท 5 points ยท Posted at 10:20:29 on June 2, 2014 ยท (Permalink)

Why is that a java specific problem? You could easily write that in another language.

Goofybud16 ยท 9 points ยท Posted at 14:18:19 on June 2, 2014 ยท (Permalink)

Because if I say all languages, someone will find some language where recursive functions are actually good.

[deleted] ยท 5 points ยท Posted at 01:54:13 on September 25, 2014 ยท (Permalink)

cough haskell cough

Goofybud16 ยท 7 points ยท Posted at 02:48:04 on September 25, 2014 ยท (Permalink)

Took 114 days, but that someone finally showed up.

Corticotropin ยท 3 points ยท Posted at 03:01:13 on June 2, 2014 ยท (Permalink)

None?

Edit: oops that's a greater-than

wave100 ยท 2 points ยท Posted at 03:33:53 on June 2, 2014 ยท (Permalink)

I winced just looking at it.

Straoos ยท 2 points ยท Posted at 14:19:13 on June 2, 2014 ยท (Permalink)

That gives me flashbacks to when we were covering recursion in a class. The professor actually put a question like that on the test...

Goofybud16 ยท 3 points ยท Posted at 14:23:20 on June 2, 2014 ยท (Permalink)

My AP test had ~5 of these...

Fuck that AP test. Also, GridWorld can hurry up and removeSelfFromCurriculum();

[deleted] ยท 1 points ยท Posted at 18:06:26 on June 2, 2014 ยท (Permalink)

And 2 of the FRQs required writting full classes.

Also you're not supposed to discuss the multiple choice!@#!@# D:

[deleted] ยท 1 points ยท Posted at 18:02:34 on June 2, 2014 ยท (Permalink)

Just answer C and move on to a question that doesnt take 5 full minutes to answer.

wave100 ยท 8 points ยท Posted at 03:33:18 on June 2, 2014 ยท (Permalink)

This is known as the Ballmer peak.

KiwiThunda ยท 10 points ยท Posted at 03:16:32 on June 2, 2014 ยท (Permalink)

I really wish I could show you the true legacy code I work with. It's 5 years old, and originally written by an outsourcing company in the Eastern Bloc.

The entire product is now coded around it. This is my nightmare.

Zeeker ยท 7 points ยท Posted at 07:01:23 on June 2, 2014 ยท (Permalink)

I raise to 11 year old 16,000 line classes

minnek ยท 6 points ยท Posted at 12:55:57 on June 2, 2014 ยท (Permalink)

Fold.

Talran ยท 1 points ยท Posted at 04:48:54 on June 2, 2014 ยท (Permalink)

To be entirely fair, I've seen people write code, and come to review like that.

[deleted] ยท 42 points ยท Posted at 20:45:43 on June 1, 2014 ยท (Permalink)

vi aint that hard man...:w :q

FTFYcent ยท 41 points ยท Posted at 20:51:08 on June 1, 2014 ยท (Permalink)

:wq

(also :x and ZZ)

frostickle ยท 16 points ยท Posted at 21:05:02 on June 1, 2014 ยท (Permalink)

:wq!

atomicUpdate ยท 29 points ยท Posted at 21:41:04 on June 1, 2014 ยท (Permalink)

The "!" is unnecessary, since you just saved with the "w", which is why the original ":wq" is better than your suggestion.

frostickle ยท 10 points ยท Posted at 21:51:50 on June 1, 2014 ยท (Permalink)

What about read only files?

HotRodLincoln ยท 14 points ยท Posted at 22:16:44 on June 1, 2014 ยท (Permalink)

Then just q!. wq! will fail. Plus you really probably want to:

:w !sudo tee %

mk48 ยท 13 points ยท Posted at 00:17:34 on June 2, 2014 ยท (Permalink)

I think that if the file is read-only, but your permissions allow you to chmod the file, wq! will do what you want.

Thelarm ยท 5 points ยท Posted at 01:16:28 on June 2, 2014 ยท (Permalink)

Best feature ever. The amount of times I use to open a file, modify it, just to be told 'lolfukuitsreadonly'. :w! is a huge life safer, especially when you've only got one TTY (And exiting the editor to chmod it would involve losing all your changes)

three18ti ยท 3 points ยท Posted at 01:42:21 on June 2, 2014 ยท (Permalink)*

Why can't you send the editor to the background ( ^Z which I guess technically is suspend and not bg but you know what I mean) chmod the file, the bring the editor back to front (fg)

Edit: with vi the "correct" way to do it is :w! when dealing with a readonly file. My suggested action is in response to the "especially when you've only got one TTY" comment. (Also, when does one ever only have one tty?)

minnek ยท 3 points ยท Posted at 12:57:48 on June 2, 2014 ยท (Permalink)

:shell

three18ti ยท 2 points ยท Posted at 17:11:38 on June 2, 2014 ยท (Permalink)

I mean... with vi the most "corrct" way to write to a read-only file is w!. But assuming not vi, and "one TTY", my solution is better than "losing all your changes"

sunshine-x ยท 1 points ยท Posted at 00:28:01 on June 2, 2014 ยท (Permalink)

Correct.

three18ti ยท 2 points ยท Posted at 01:38:56 on June 2, 2014 ยท (Permalink)*

:w !sudo tee %

deliciousnaga ยท 13 points ยท Posted at 20:50:51 on June 1, 2014 ยท (Permalink)

I don't know how to use vi except for those two.

[deleted] ยท 7 points ยท Posted at 21:06:11 on June 1, 2014 ยท (Permalink)*

[deleted]

[deleted] ยท 5 points ยท Posted at 01:37:05 on June 2, 2014 ยท (Permalink)

I like how a lot of the write and exit commands look like smileys.

outadoc ยท 3 points ยท Posted at 06:47:29 on June 2, 2014 ยท (Permalink)

:c

maryjayjay ยท 8 points ยท Posted at 23:23:43 on June 1, 2014 ยท (Permalink)

Evey emacs user in the world can use vi more proficiently than most vi users, but still prefers emacs.

(I could use a good flame war)

MrPopinjay ยท 5 points ยท Posted at 00:27:28 on June 2, 2014 ยท (Permalink)

What makes you say that?

0xFFE3 ยท 9 points ยท Posted at 01:29:45 on June 2, 2014 ยท (Permalink)

Well, they're bored, and haven't had a good circlejerk about how awesome vi is recently, so they're pretending to like emacs.

sunshine-x ยท 4 points ยท Posted at 00:28:48 on June 2, 2014 ยท (Permalink)

You had me till the last line. Almost got hot in here!

dotted ยท 2 points ยท Posted at 22:11:28 on June 1, 2014 ยท (Permalink)

So how do you write colons?

MagnetScientist ยท 17 points ยท Posted at 22:15:59 on June 1, 2014 ยท (Permalink)

Vi works with different modes. In INSERT mode, you can type every character and it gets inserted in the text. With ESC, you go to NORMAL mode; there, keys represent actions.

[deleted] ยท 3 points ยท Posted at 22:17:03 on June 1, 2014 ยท (Permalink)

i start with INSERT, then type whatever you want, hit Escape, then :w and :q. Easy peasy.

[deleted] ยท 2 points ยท Posted at 01:37:46 on June 2, 2014 ยท (Permalink)

I just use :wq!

BJ2K ยท 2 points ยท Posted at 06:33:23 on June 2, 2014 ยท (Permalink)

Yeah her ult is pretty much free kills.

[deleted] ยท 1 points ยท Posted at 18:56:13 on June 2, 2014 ยท (Permalink)

Ctrl+z
kill %1

Is how I always killed it. Until I discovered syntax highlighting and vless to read our fucking logs that less wouldn't color.

OKB-1 ยท -18 points ยท Posted at 21:23:38 on June 1, 2014 ยท (Permalink)

Any IDE that doesn't allow you to just type text without having to memorise 100 shortcuts is way too hard to use if you ask me. But I'm probably a compleet amateur for thinking that.

DrummerHead ยท 27 points ยท Posted at 21:29:50 on June 1, 2014 ยท (Permalink)*

Vim is not even an ide

Just give it a try for a month and see if it jives with your mojo

Edit: don't downvote the guy, he's expressing his opinion and honestly it's a valid one. Vim is hard to learn and also really useful, until you don't feel the power all you see is a shittone of shortcuts you're supposed to learn.

[deleted] ยท 7 points ยท Posted at 21:41:46 on June 1, 2014 ยท (Permalink)*

[deleted]

DinsFire64 ยท 5 points ยท Posted at 00:04:09 on June 2, 2014 ยท (Permalink)

Agreed.

Forcing yourself to do something is how I got addicted to both vim and LaTeX.

PaplooTheEwok ยท 1 points ยท Posted at 03:59:10 on June 2, 2014 ยท (Permalink)

My data structures class starts tomorrow and I think they're forcing us to use emacs. Looking forward to trying it out!

sunshine-x ยท 6 points ยท Posted at 00:29:54 on June 2, 2014 ยท (Permalink)

Correct. Just like any car that requires you to shift is way too hard to use.

OKB-1 ยท 1 points ยท Posted at 05:26:44 on June 2, 2014 ยท (Permalink)

That is probably a very good analogy.

Pokechu22 ยท 2 points ยท Posted at 22:03:43 on June 1, 2014 ยท (Permalink)

Vi/Vim is more for moving about text and doing crazy stuff. I don't use it, but apearently it is very fast once you know it.

I work with notepad++, and it does what I need.

sunshine-x ยท 4 points ยท Posted at 00:32:14 on June 2, 2014 ยท (Permalink)

Notepad++ a bitch to use via a terminal...

Jess_than_three ยท 6 points ยท Posted at 02:34:54 on June 2, 2014 ยท (Permalink)

I work with notepad++, and it does what I need.

You'd almost imagine that "what Pokechu22 needs" doesn't require editing text via a terminal!

sunshine-x ยท 2 points ยท Posted at 03:22:40 on June 2, 2014 ยท (Permalink)

Maybe he likes using rsync to sync his files bidirectionally.

Jess_than_three ยท -1 points ยท Posted at 22:59:32 on June 1, 2014 ยท (Permalink)

Same. I love Notepad++ to death, and while I haven't used vi extensively, I don't think I'll ever understand why someone would prefer to use a text editor that you can't use a mouse with.

29083011397778 ยท 5 points ยท Posted at 23:20:23 on June 1, 2014 ยท (Permalink)

As a Linux user with Vimium for chrome, mouse is hereby defined thusly:

"Mouse: Peripheral used for gaming, often in conjunction with the Windows operating system."

I use the terminal for almost everything else, and extensive keyboard shortcuts to get around. That said, I will quickly and happily admit it's not for everyone.

Jess_than_three ยท 1 points ยท Posted at 23:25:47 on June 1, 2014 ยท (Permalink)

I'm sure that makes a ton of sense for you and for the way you use your computer! For me, I'm a Windows user (although I've worked with Ubuntu some, including a bit of command-line stuff, and a bit of vim), so that's what's intuitive for me..

flukus ยท 4 points ยท Posted at 02:18:27 on June 2, 2014 ยท (Permalink)

You can use a mouse with gvim. Personally I don't know why you'd want to use a mouse for editing text.

Jess_than_three ยท 2 points ยท Posted at 02:29:38 on June 2, 2014 ยท (Permalink)

Um... scrolling? Selecting? Moving your cursor from one place to another? Copying and pasting? Switching between documents in different tabs, or between the document and a browser window in which I'm doing relevant research, or a spreadsheet with data related to whatever project I'm working on, or PHPMyAdmin?

Personally I don't know why you'd want to use a keyboard for navigation....

csolisr ยท 4 points ยท Posted at 02:38:19 on June 2, 2014 ยท (Permalink)

If you've memorized all the required shortcuts by rot, all of the above can be done with a few carefully selected keystrokes instead of moving the mouse here and there. If not, yes, of course the mouse is much more intuitive to use.

[deleted] ยท 1 points ยท Posted at 02:34:41 on June 2, 2014 ยท (Permalink)

You can use a mouse with vim, though obviously it's subject to the limitations of the terminal itself.

More to the point, I spend a great deal of time working on non-local systems, and not all of those systems have GUIs installed. Stuff like Notepad++ doesn't work in a terminal, and vim actually gives me more than notepad++ does with plugins. For example, I can highlight code and press a key combo to toggle commenting it out and it will work for whatever language the file is. I've got things like git blame and ack-grep built right into the editor, and various other handy shortcuts. It also works as a diff viewer / conflict resolver.

Jess_than_three ยท 0 points ยท Posted at 02:41:47 on June 2, 2014 ยท (Permalink)

Yup, that's fair! I don't have any need to edit text in a terminal, or, well, most of what you're referencing. As far as automatic commenting, that does sound pretty handy, although personally the only languages I need to comment in are PHP and HTML - the latter would be nice to have a key-command for, I guess, but PHP's really easy to comment things out in. And I think Notepad++ has a diff viewer now? Not sure.

Anyway, definitely down to whatever your use case requires, I suppose.

LyndonArmitage ยท 1 points ยท Posted at 12:42:48 on June 2, 2014 ยท (Permalink)

I think Notepad++ has a comment key? Ctrl+Q maybe? I taught myself the basics of Vim over a weekend and will use it whenever I am on a Linux machine unless the project will benefit from using a proper IDE, it feels much more natural to not touch the mouse when editing text as it doesn't interfere with your flow as much.

Jess_than_three ยท 1 points ยท Posted at 18:08:35 on June 2, 2014 ยท (Permalink)

That's fair. :)

[deleted] ยท 2 points ยท Posted at 22:17:56 on June 1, 2014 ยท (Permalink)

because Ctrl+C, CTRL+X, CTRL+V are just too easy for even the noobish of mortals?

[deleted] ยท 3 points ยท Posted at 02:32:11 on June 2, 2014 ยท (Permalink)

Except that those don't work in the terminal for various reasons. Not even for nano/pico. If I'm editing a file on a remote headless system, it's not terribly efficient to copy the file back and forth just so I can use a GUI-based text editor.

TuctDape ยท 2 points ยท Posted at 21:43:31 on June 1, 2014 ยท (Permalink)

You need two know exactly 1 shortcut to begin entering text

HotRodLincoln ยท 1 points ยท Posted at 22:32:21 on June 1, 2014 ยท (Permalink)

It depends on if it recognizes arrow keys which it sometimes doesn't when you're using it over ssh. So, really you need to know:

Escape - switch out of insert (typing) mode to editing (key commands/navigation) mode.
o, i, a - enter insert mode in different ways : - ex commands
:q - quit
:w - write/save

So, you really need a few concepts and commands to do anything useful with vim, but they can all fit easily on a single page.

mort96 ยท 2 points ยท Posted at 23:23:08 on June 1, 2014 ยท (Permalink)

What? I've never experienced arrow keys not working over SSH, and I've used OpenSSH with iTerm 2 and the default terminal on OS X, xTerm in Ubuntu, Debian and Fedora, and Putty on Windows.

HotRodLincoln ยท 2 points ยท Posted at 00:05:59 on June 2, 2014 ยท (Permalink)

It's a common issue with many causes.

sunshine-x ยท -1 points ยท Posted at 00:31:18 on June 2, 2014 ยท (Permalink)

It's not common. More often than not, it's due to a distro not including Vim, and providing just old-school vi in my experience.

HotRodLincoln ยท 5 points ยท Posted at 00:44:28 on June 2, 2014 ยท (Permalink)

That is indeed one of the 20 documented issues.

Koneke ยท 1 points ยท Posted at 06:54:28 on June 2, 2014 ยท (Permalink)

a, v, and d is enough to enter and delete text.

mirx ยท 9 points ยท Posted at 20:24:15 on June 1, 2014 ยท (Permalink)

Surprisingly accurate

tigerstorms ยท 26 points ยท Posted at 22:58:24 on June 1, 2014 ยท (Permalink)

he missed some:

What we say What we mean
I broke it to make it work I have no idea how I fixed it
It was working and now it's not I have no idea how I broke it
I found a quick fix I downloaded the code online
I helped others find a solution I shared this code online
Hydrothermal ยท 30 points ยท Posted at 01:28:14 on June 2, 2014 ยท (Permalink)

Don't forget:

What we say What we mean
I outsourced the work on a one-time contract I asked a question on StackOverflow and copy-pasted the answer
Stall0ne ยท 7 points ยท Posted at 17:45:52 on June 2, 2014 ยท (Permalink)

More like "It took a lot of research but I figured it out"

FecklessFool ยท 10 points ยท Posted at 21:42:31 on June 1, 2014 ยท (Permalink)

If it's a horrible hack or a crappy work around I comment it as it is and leave a little explanation on why it was done like that. I have long given up on calling those things temporary todos as I never get to revisit any of them much as I would like.

Play_Rust ยท 2 points ยท Posted at 21:22:05 on June 1, 2014 ยท (Permalink)

The structure one is so damn true.
"We need to rewrite it" I usually just leave it, If it works and I don't know why then why fix it?

TakeoKuroda ยท 4 points ยท Posted at 12:35:23 on June 2, 2014 ยท (Permalink)

Self-Documenting = My code is pretty enough. You should understand this.

williamfwm ยท 5 points ยท Posted at 18:04:00 on June 2, 2014 ยท (Permalink)
"It's trivial to...." | "It's complicated but I'm smarter than you"
IIIIIIIIIIl ยท 17 points ยท Posted at 21:48:08 on June 1, 2014 ยท (Permalink)

LOL the quitting vi is the best

HeroesGrave ยท 14 points ยท Posted at 23:04:38 on June 1, 2014 ยท (Permalink)

Do you ever log out of Reddit and forget your username?

Jonathan_the_Nerd ยท 41 points ยท Posted at 23:22:26 on June 1, 2014 ยท (Permalink)

What is "log out of Reddit"?

RenaKunisaki ยท 34 points ยท Posted at 23:55:28 on June 1, 2014 ยท (Permalink)

It's when you switch to a throwaway account.

Oneusee ยท 10 points ยท Posted at 01:47:33 on June 2, 2014 ยท (Permalink)

Shit, what happened to RES? I don't even know my passwords by now.

SeriousJack ยท 4 points ยท Posted at 14:24:40 on June 2, 2014 ยท (Permalink)

Logged on my reddit account on a friend's computer once. To get a saved link.

Went on the "saved links" section. RES was not installed. Hence, the NSFW filter wasn't on either.

Awkwardness ensued.

Oneusee ยท 1 points ยท Posted at 14:42:25 on June 2, 2014 ยท (Permalink)

Did you download RES for him?

SeriousJack ยท 2 points ยท Posted at 14:50:31 on June 2, 2014 ยท (Permalink)

Of course. Life without RES is too complicated.

flukus ยท 2 points ยท Posted at 02:20:05 on June 2, 2014 ยท (Permalink)

Isn't that the point of having multiple browsers?

HeroesGrave ยท 7 points ยท Posted at 02:28:39 on June 2, 2014 ยท (Permalink)

Well if it isn't...

...then I'm not sure why IE exists.

Goofybud16 ยท 1 points ยท Posted at 02:52:38 on June 2, 2014 ยท (Permalink)

I use it, Modern IE (The Windows 8 fullscreen one) works beautifully.

Note: Only on my tablet

IIIIIIIIIIl ยท 4 points ยท Posted at 01:27:59 on June 2, 2014 ยท (Permalink)

logout?

Triapod ยท 7 points ยท Posted at 23:44:26 on June 1, 2014 ยท (Permalink)

This would be the perfect time for an ed joke but I'm still trying to exit.

LostAtSeaWorld ยท 3 points ยท Posted at 00:48:48 on June 2, 2014 ยท (Permalink)

That last one hits home hard. I just started an internship last week and was asked to do some stuff in vi. Had to sheepishly ask for assistance exiting the editor after trying an essentially arbitrary combination of esc's, q's, w's, and x's.

Earthborn92 ยท 9 points ยท Posted at 04:11:35 on June 2, 2014 ยท (Permalink)

I had the same problem a couple of months back.

Go and take some time to read the docs. You don't need to memorize everything... Just essentials.

Trust me, it's worth it.

LostAtSeaWorld ยท 1 points ยท Posted at 05:12:28 on June 2, 2014 ยท (Permalink)

For sure, would definitely make things run smoother without having to flip back and forth between the docs / stack overflow while working.

n1c0_ds ยท 2 points ยท Posted at 15:36:14 on June 2, 2014 ยท (Permalink)

Esc, :q always works. Take 10 minutes to learn the basics, then set your default editor to nano.

[deleted] ยท 1 points ยท Posted at 19:24:44 on June 2, 2014 ยท (Permalink)

LOL..."learn how to use Vi...then use something else."

n1c0_ds ยท 2 points ยท Posted at 21:13:48 on June 2, 2014 ยท (Permalink)

Learn to exit vi, then use something else. It's really easy to understand the escape-i loop.

Orbital431 ยท 3 points ยท Posted at 05:05:34 on June 4, 2014 ยท (Permalink)

Lol'd at the vi one, hehehe. I find with beer, ProgrmerHumor is slightly more humorous than I think it is

narangutang ยท 16 points ยท Posted at 21:01:50 on June 1, 2014 ยท (Permalink)

I don't know how to quit vi 10/10

+/u/dogetipbot megaflip verify

[deleted] ยท 8 points ยท Posted at 22:21:50 on June 1, 2014 ยท (Permalink)

Oh, the coder's tip?

thirdegree ยท 5 points ยท Posted at 01:25:24 on June 2, 2014 ยท (Permalink)

+/u/dogetipbot 4.20 doge verify seems a bit closer IMO.

dogetipbot ยท 3 points ยท Posted at 01:26:36 on June 2, 2014 ยท (Permalink)

[wow so verify]: /u/thirdegree -> /u/Kinkzoz ร4.2 Dogecoinsย ($0.00170419) [help]

dogetipbot ยท 6 points ยท Posted at 21:02:24 on June 1, 2014 ยท (Permalink)

[wow so verify]: /u/narangutang -> /u/TW80000 ร44 Dogecoinsย ($0.0179063) [help]

sirtophat ยท 4 points ยท Posted at 00:43:13 on June 2, 2014 ยท (Permalink)

I've been using vim for 10 years, mostly because I can't figure out how to close it

narangutang ยท 0 points ยท Posted at 00:50:36 on June 2, 2014 ยท (Permalink)

HAHAHAHAHA this is awesome. Have some doge :D

+/u/dogetipbot megaflip verify

dogetipbot ยท 3 points ยท Posted at 00:50:53 on June 2, 2014 ยท (Permalink)

[wow so verify]: /u/narangutang -> /u/sirtophat ร12 Dogecoinsย ($0.00486912) [help]

sirtophat ยท -2 points ยท Posted at 00:58:33 on June 2, 2014 ยท (Permalink)

hah thanks

RedPanda_UA ยท 2 points ยท Posted at 15:30:53 on June 2, 2014 ยท (Permalink)

This is pure gold!

[deleted] ยท 2 points ยท Posted at 23:36:44 on June 1, 2014 ยท (Permalink)

[deleted]

cdrt ยท 12 points ยท Posted at 00:01:51 on June 2, 2014 ยท (Permalink)

"Our code is work well today, comrade."

kim05ab3 ยท 6 points ยท Posted at 23:48:52 on June 1, 2014 ยท (Permalink)

"Our" is a possessive pronoun.

halflife22 ยท 7 points ยท Posted at 00:32:06 on June 2, 2014 ยท (Permalink)

That company is screwed.

[deleted] ยท 1 points ยท Posted at 00:36:38 on June 2, 2014 ยท (Permalink)

I prefer not hiring the kind of people that would speak in such a clearly uncooperative manner. Code ownership/ responsibility can improve return times on bug fixing and new features, and it can be healthy to foster it in critical, and rapidly changing, areas.

Forcing people to use "our code" just strips all personal feeling from code, which is demoralising. Programmers aren't all communal robots.

[deleted] ยท 1 points ยท Posted at 23:09:24 on June 1, 2014 ยท (Permalink)

Hahaha the vi one at the bottom made me actually lol

thenextvh ยท 1 points ยท Posted at 03:03:22 on June 2, 2014 ยท (Permalink)

LOL at the last one

DocMcNinja ยท 1 points ยท Posted at 03:54:23 on June 2, 2014 ยท (Permalink)

I don't really use vi a lot at all, but occasionally had to so that I learned how to quit it. Then, in a job interview, it accidentally opened in Git for Windows when commit did not have a message in it, and vi was the default comment editor. That's when I didn't know how to exit it (apparently there is some key combination one is supposed to press before it starts receiving commands).

Earthborn92 ยท 2 points ยท Posted at 04:08:14 on June 2, 2014 ยท (Permalink)

ESC :q!

Always works I think.

5225225 ยท 1 points ยท Posted at 06:35:26 on June 2, 2014 ยท (Permalink)

key combination

: for commands. :q to quit (You might have to press ESC or Ctrl+C to go into normal mode, I think ^C works in vi, not sure though.)

knobbysideup ยท 1 points ยท Posted at 01:01:31 on June 2, 2014 ยท (Permalink)

Perl is the only language I can step away from for a significant amount of time and come back to write useful stuff without needing a book to remember how. Maybe because it lets you adopt your own style. I'll take perl over that php abortion any day.

acwsupremacy ยท 0 points ยท Posted at 01:02:11 on June 2, 2014 ยท (Permalink)

I lost it at "I don't know how to quit vi."

droogans ยท 0 points ยท Posted at 20:09:27 on June 1, 2014 ยท (Permalink)

I say that last one out loud every time I find myself in the staging server's /etc/ directory.

reddittopcomments ยท 0 points ยท Posted at 02:00:15 on June 2, 2014 ยท (Permalink)

how do you exit vi...

EdricStorm ยท 5 points ยท Posted at 02:16:09 on June 2, 2014 ยท (Permalink)

:q!

Thimble ยท 0 points ยท Posted at 05:08:25 on June 2, 2014 ยท (Permalink)

This hits too close to home for me to laugh at. I did the complex structure one just recently: "you should probably read through the code carefully before making any changes because it's kind of complicated." i.e. the code structure is shit. In my defence, I didn't start the project and they eventually fired the guy who did for being incompetent.

GeneticsGuy ยท 0 points ยท Posted at 06:13:53 on June 2, 2014 ยท (Permalink)

As a perl programmer, I laughed :)

FuckFrankie ยท -6 points ยท Posted at 00:54:51 on June 2, 2014 ยท (Permalink)

These are script kiddie words. I can tell because they don't want to pay programmers a real salary.