We've recently received a Vim golf question that's sparked a bit of controversy as to whether Vim golf, or "editor golf" in general, is on-topic here.

Should Vim, Emacs, or editor golf in general be allowed?

  • 7
    \$\begingroup\$ I'd really like to see more of these, but currently all we have are explicit vim golf question. I think where possible (which is probably almost always the case), we should apply our usual guidelines of "don't make it language specific unless it only makes sense in one language" rules here, and actually make these general "editor golf" challenges as you say. We also need to sort out if Shift, Ctrl and Alt are counted as keystrokes. \$\endgroup\$ Commented Feb 24, 2015 at 15:26
  • 1
    \$\begingroup\$ I am not going to answer this one. But regarding shift, Ctrl, Alt. In the recent vim golf, where keystrokes was the criteria, people treated both lower and upper case as being single keystroke, without treating the caps lock in between each case shuffle or shift key as a separate keystroke. \$\endgroup\$
    – Optimizer
    Commented Feb 24, 2015 at 16:57
  • 3
    \$\begingroup\$ Re - modifier keys: I would not count Shift/Ctrl/Alt. You wouldn't count, say, A as one character longer than a in a code golf challenge, and it is possible to encode a literal "ctrl+a," for example, with <C-v><C-a> within Vim. \$\endgroup\$
    – Doorknob
    Commented Feb 24, 2015 at 17:08

1 Answer 1


Yes, I think "editor golf" is perfectly on-topic here, assuming solutions are submitted entirely in keystrokes and not, for example, with mouse clicks or menu buttons.

  • Vim, Emacs, and most other text-based editors have a way to execute arbitrary keystrokes, making a sequence of keystrokes almost like a "program." For example, one can execute Vim keystrokes from the command line like so:

    $ echo 'Input' > file.txt
    $ vim '+normal (enter keystrokes here...)' '+wq' file.txt
    $ cat file.txt  # output

    Or, they can be noremapped to a key and this key can be pressed within Vim to "run" the "program."

  • It's an objective winning criterion. "Least keystrokes" is just as effective as "least characters." Kind of like a specialized .

  • Some may argue that Vim, Emacs, or other editor keystrokes should not be considered a "programming language." However, we can take the premise that, for example, regex solutions are considered on-topic here. Vim can apply regular expression substitutions to the input file, making Vim a superset of regex. Hence, Vim should be considered a programming language as well.

    Specifically, from our semi-"official" definition of a programming language:

    • Support a representation of natural numbers and of tuples - Yes. Vim can handle numbers via <C-a> and <C-x> (or with regex), and typically operates linewise, making the entire file effectively a "tuple" with each line acting as an element.

    • Be able either to transform inputs into outputs - We can stop right here, because of course Vim can transform an input file into a distinct output file.

    • Be able to take two natural numbers and add them - Vim can do this with several methods: using certain lines within Vimscript expressions themselves (with getline), using Vim's built-in Python or Ruby capabilities (hey, more proof that Vim is a superset of other languages), editing lines into Vimscript, yanking them, and executing them via @, etc.

    • Be able to take a natural number and say whether or not it is a prime - Same as above.

  • Another argument is that all answers here should contain code, and keystrokes are not code. I'd argue that keystrokes are indeed code, as Vim, Emacs, etc. can be programmed (via their .vimrc or .emacs files) in terms of keystrokes, and Vimscript/Elisp are their own programming languages.

  • 17
    \$\begingroup\$ So, Vim golf is perfectly on-topic. But Emacs? No way we're letting that blasphemy anywhere near our site. :P \$\endgroup\$
    – Doorknob
    Commented Feb 24, 2015 at 15:20
  • \$\begingroup\$ How would you compare keystrokes with bytes? \$\endgroup\$
    – Dennis
    Commented Feb 4, 2016 at 16:20
  • 1
    \$\begingroup\$ @Dennis Almost all keystrokes are single bytes. This is obvious for printable ASCII, Ctrl+A-Z are represented as 1-26, Escape is 27, etc., and Alt+{character} is simply {character} with the high bit set. These work with the command line execution method detailed in my answer (try putting a literal Escape character into the string being passed to vim, for example). \$\endgroup\$
    – Doorknob
    Commented Feb 4, 2016 at 17:32
  • 9
    \$\begingroup\$ @Doorknob Did you just answer your own question on meta, and make a funny comment on said answer, also by yourself? \$\endgroup\$ Commented Sep 2, 2016 at 5:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .