Write a Vim command that reads as English text

2

2

Once you grok vi, your muscle memory learns tricks like ggVGx to delete all the text in a file. Trouble is, ggVGx is not an English word, so it makes a terrible mnemonic.

This challenge is about constructing a single Vi[m] command that can be reasonably read as an English word, phrase or sentence. One point per letter.

Modifier keys such as meta/alt, control, and shift should be written as they are in VimScript, e.g. <C-c> so we can read them, but will be pronounced as two consecutive letters: cc, for a score of 2.

Vim commands that start with : are only count toward your scrore if they build a word out of non-words. So :%s/aword/anotherword/gi would only add 3 to your score, for sgi (and only then if sgi is part of an actual English word or phrase, such as hasgills. Similarly :help would add zero to your score.

No user-defined mappings. Your answer should work on a fresh install of Vim with no .vimrc or other gizmos.

Finally, the command has to do something other than throw an error.

Example Entry:

cap (3)

cap, change a paragraph

hoosierEE

Posted 2014-05-29T01:19:37.653

Reputation: 760

Question was closed 2016-04-19T15:31:56.963

Are you excluding commands that start with :? Most of them are pretty obviously English words. – Greg Hewgill – 2014-05-29T01:26:33.960

ah good point, updating... – hoosierEE – 2014-05-29T01:37:52.800

Wait, people still use vim? Don't they know that it's 2014? – Kyle Kanos – 2014-05-29T01:38:04.660

1The proper command to delete the entire buffer is obviously ggdG (or Gdgg) – Geoff Reedy – 2014-05-29T02:19:55.353

Slightly related, someone on SO asked for a way to "insert a space in normal mode," so I gave him a mapping that would insert a space any time he typed the keys space. – Kevin – 2014-05-29T02:47:50.850

2@KyleKanos Wait, you mean there's people who don't use vim? – Kevin – 2014-05-29T02:48:14.440

@Kevin but did you make it so spaaace inserted 3 spaces, etc? – hoosierEE – 2014-05-29T02:51:13.150

Which brings up another point. We can't just use mappings, right? – Kevin – 2014-05-29T02:51:55.700

Correct, no mappings. I assumed that would fall under the standard loopholes, but I'll add it to the question to be clear. – hoosierEE – 2014-05-29T02:58:26.543

This question is offensive to my religion – Digital Trauma – 2014-05-29T03:52:53.987

Answers

10

Score 60

:s/foo/bar/incerepellingliceingreeceIgrillripeninggreenpepperinniceice

since repelling lice in Greece I grill ripening green pepper in nice ice

You can repeat flags arbitrarily in the :s command so this can get as long as you care to come up with a sentence/phrase/word using only the letters c,e,g,i,I,n,p,l,r and starting with an s.

Geoff Reedy

Posted 2014-05-29T01:19:37.653

Reputation: 2 828

14That's ridiculous. Grilling with nice ice just makes a bunch of steam. – hoosierEE – 2014-05-29T03:18:03.360

4

I think this a really cheesy answer.

Prints " think this is a really cheesy answer.", score of 36. If you count "anything typed in insert mode" as one point, we can construct arbitrarily long cheesy strings like this:

I think really cheesy answers are accidents. No really, they're accidents. I mentioned they're accidents, right?

Where each cc in "accident" is the <Ctrl-C> insert mode command. The following i puts us back in insert mode for an additional two characters whenever we write "accident". If we have to end in normal mode, we can finish the paragraph with:

But I really like soccer!

Which leaves insert mode, moves to the end of the last word, and replaces the last character with a !.

Hovercouch

Posted 2014-05-29T01:19:37.653

Reputation: 659

4

Haven't spent much time, but found at least one 6-letter word which is a valid command: toggle (go to next letter 'o', then jump to beginning of file, then second line and to the end of a first word there). I am sure there could be a lot of other words combined from movement commands.

Found another one. This one at least does something (and is 7 letters): forgery (go to 'o', replace with 'g', go to end of word, replace with 'y').

More words and phrases:

Brand new
Entangled<space>
Su<cc>ulents

aragaer

Posted 2014-05-29T01:19:37.653

Reputation: 431

Nice ones! forgery especially. – hoosierEE – 2014-05-30T13:04:43.790

3

Vim's text objects provide a variety of three-letter words (of which cap is one).

grep -E '^[cdv][ai][wspbt]$' /usr/share/dict/words
  • cab
  • cap
  • cat
  • caw
  • cis
  • cit
  • dab
  • dap
  • das
  • dat
  • daw
  • dib
  • dip
  • dis
  • dit
  • vas
  • vat
  • vaw
  • vip
  • vis

I only found one four letter command that is a word:

  • guib

I opted not to include insert mode commands such as a, r, s where the remainder of the "word" is just text typed into the document. Otherwise, you would have to accept any word starting with one of those letters.

Greg Hewgill

Posted 2014-05-29T01:19:37.653

Reputation: 2 641

This answer definitely fits with what I had in mind when I asked the question. No loopholes (standard or non), but it seems a bit odd that they're all 3 characters long. – hoosierEE – 2014-05-29T20:41:33.747

Found a four letter one. – Greg Hewgill – 2014-05-29T21:01:26.737