16
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ -1 for mentioning Notepad. \$\endgroup\$ Jun 28, 2011 at 0:55
  • 7
    \$\begingroup\$ user unknown: That's a quite stupid reason for downvoting, actually. \$\endgroup\$
    – Joey
    Jun 28, 2011 at 19:49
  • 3
    \$\begingroup\$ @Joey Don't try to find logic in a fanboy's reasoning. \$\endgroup\$
    – Marcelo
    Jun 29, 2011 at 19:36
  • 2
    \$\begingroup\$ You should add an objective winning criterium, like amount of votes or character/byte count. \$\endgroup\$
    – overactor
    Aug 30, 2014 at 22:36

3 Answers 3

11
\$\begingroup\$

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?

\$\endgroup\$
6
  • \$\begingroup\$ All I get is a file containing ":wq" followed by a couple newlines. \$\endgroup\$
    – Joey Adams
    Jun 27, 2011 at 19:42
  • \$\begingroup\$ Oops, I've mangled the sequence. Will fix in a moment. \$\endgroup\$ Jun 27, 2011 at 19:52
  • \$\begingroup\$ 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. \$\endgroup\$
    – asoundmove
    Jun 27, 2011 at 23:44
  • \$\begingroup\$ Also, by <kbd>A</kbd>, do you mean <kbd>Shift</kbd>+<kbd>a</kbd> ? \$\endgroup\$
    – Joey Adams
    Jun 28, 2011 at 0:51
  • \$\begingroup\$ @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! \$\endgroup\$ Jun 28, 2011 at 2:25
4
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.