Compose a Vim quine!

16

2

Goal:

Create and save file in Vim containing at least 25 ASCII characters. The exact keystrokes used during the creation and saving of this file must also produce identical contents in Windows Notepad (without having to save in Notepad).

Rules:

  • For the purposes of this challenge, Vim begins open in command mode.
  • The mouse is not allowed.
  • Shift is allowed. Ctrl, alt, or any other modifier keys are not allowed.
  • Your solution must work with the default "terminal" (non-GUI) Vim shipped with either Ubuntu 11.04 or OS X 10.6.7 (one of the two). Assume this Vim's .vimrc contains only set nocompatible (with no line break after it), which is itself located at ~/.vimrc. Pretend your operating system was just installed before opening Vim.
  • You must not open any pre-existing files except for your .vimrc. Any files you create while solving this puzzle may be saved and re-opened as many times as necessary.
  • Vim cannot be closed!

Disclosure, and a possible reason to close: I do not have a solution.

ClosureCowboy

Posted 14 years ago

Reputation: 295

Question was closed 11 years ago

-1 for mentioning Notepad. – user unknown – 14 years ago

6user unknown: That's a quite stupid reason for downvoting, actually. – Joey – 14 years ago

3@Joey Don't try to find logic in a fanboy's reasoning. – Marcelo – 14 years ago

2You should add an objective winning criterium, like amount of votes or character/byte count. – overactor – 11 years ago

Answers

11

The edited sequence (the first version was mangled).

2 A 2 A Esc 2 A 2 A Esc 2 A 2 A Esc

2 A 2 A Esc 2 A 2 A Esc 2 A 2 A Esc

2 A 2 A Esc 2 A 2 A Esc A : w q Enter

Esc Backspace Backspace Backspace Backspace Backspace : w q Enter

Should do the trick, if I'm counting my keystrokes correctly. No wait, is the escape key allowed?

n. 'pronouns' m.

Posted 14 years ago

Reputation: 346

All I get is a file containing ":wq" followed by a couple newlines. – Joey Adams – 14 years ago

Oops, I've mangled the sequence. Will fix in a moment. – n. 'pronouns' m. – 14 years ago

Hmmm, what about the Vim cannot be closed requirement? I suppose the solution is simple enough: remove the two q's and one of the backspaces. – asoundmove – 14 years ago

Also, by <kbd>A</kbd>, do you mean <kbd>Shift</kbd>+<kbd>a</kbd> ? – Joey Adams – 14 years ago

@asoundmove ah yes, missed that part. Removing both "q"s and a backspace should fix it. @Joey Adams; I mean Shift+A indeed, but this notation takes too much space, enough is enough! – n. 'pronouns' m. – 14 years ago

Awesome. Well done. :) – ClosureCowboy – 14 years ago

4

I Backspace H E L LO , Space W O R LD

Esc Shift+; W Enter I Backspace Backspace Backspace Backspace.

Produces "hello, world" in both.

Ry-

Posted 14 years ago

Reputation: 5 283

1

34 keystrokes. Produces twenty-two A's followed by :x and a new line.

i Backspace

a a a a a a a a a a a

a a a a a a a a a a a

: x Enter Esc Backspace Backspace Backspace : x Enter

Fraxtil

Posted 14 years ago

Reputation: 2 495