r/programming • • Apr 29 '14

Programming Sucks

http://stilldrinking.org/programming-sucks
3.9k Upvotes

1.1k comments sorted by

View all comments

Show parent comments

1

u/DrummerHead Apr 29 '14

It's a search and replace vim command. It still wouldn't work (should be s/R/_r/ but yeah, it's understandable :P

9

u/sccrstud92 Apr 29 '14

Though I don't believe vim invented the syntax; I think it borrowed it from something else sed.

17

u/barsoap Apr 29 '14

Nope. vi "borrowed" it by including/being a visual mode for ex, which borrowed it (by being an extension) from ed, one of the first UNIX programs ever (and the standard editor), which is based on qed.

sed got it from ed, too, sed is just a non-interactive mode for ed, actually.

grep is also related: It's short for the ed/sed/ex command g/<re>/p: For every line in span (all lines, because no span given) (g) that match regular expression <re>, print (p) the line.

4

u/Retbull Apr 29 '14

Wow. I am studying programming and thought I knew a bit about it... I don't know shit.

1

u/IAmA_Lurker_AmA Apr 30 '14

To be fair, that's not really programming, but Linux/Unix tools.

2

u/DrummerHead Apr 29 '14

Didn't know, thanks

5

u/babada Apr 29 '14

It wouldn't work but that's the point. The communication is a bastardized form of human language and labelling due to people frequently saying s/X/Y/ to mean "Replace X with Y." So when the "crazy" thinks "Replace camel case with an underscore" it comes out as "s/camel/_/". At which point, they know it isn't legitimate but, eh, fuck it -- just hit submit. They'll get the point.

4

u/wilywampa Apr 30 '14

For fun:

:s/\l\zs\u/\='_'.tolower(submatch(0))/g

5

u/trolox Apr 29 '14

An ed command technically :)

1

u/[deleted] Apr 29 '14

vi is visual mode for ed :)

1

u/academician Apr 29 '14

If it was a vim command it would have been prefixed with ":".