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?
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 atomic-code-golf.
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-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
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
.emacs files) in terms of keystrokes, and Vimscript/Elisp are their own programming languages.