On 2013-11-25 20:16, Devon Terrell wrote:
> I'm interested in studying the structure of the command language of
> Vim. Several people have likened Vim's command structure to a
> formal language
> (http://yanpritzker.com/2011/12/16/learn-to-speak-vim-verbs-nouns-and-modifiers/)
> and I'd like to take a closer look at it as such.
>
> One of the things I like to do is to construct a hierarchy of the
> commands in Vim. If a user enters 'c' in command mode, what are
> all of the possible choices for their next input character that
> would map to a valid command (like 'a', 'i', etc).
The yanpritzker link you include covers most of that. They usually
follow the form
{count}{action}{motion}
where {count} defaults to 1, and {action} defaults to "move" if
unspecified. Often, if the character used for the {motion} is the
same character as the {action}, it performs the action on the whole
line (e.g., "dd", "yy", ">>", "<<", "cc"). The link above highlights
text-objects as special {motion}s.
The more-interesting ones (to me) are those where that grammar doesn't
hold:
- "s", "a", "A", "i", "I", "gI" (don't take a motion)
- "^", "'"/"`" (ignore a count)
- "m" (ignore a count and action)
- "v"/"V"/"^V" (somewhat swap the grammar to
{count}{motion}{count}{action})
> In addition, a hierarchical structure could be analyzed to look for
> open sequences of commands for new plugins or remapping of commonly
> used commands, or in an attempt to redesign the command structure
> to make it more compact, i.e. fit into a shorter tree
> representation.
I keep a rough mental model of such a map in my head which is easy
(it's the aforementioned outliers that take work).
> Has this been done before? Has there been much research done on
> the Vim command structure itself (not VimScript) as a language? Is
> there a map out there somewhere that shows every possible vim
> command (with reasonable limits, like not including
> '/searchForwhateverYouWant' and similar commands)? Could a script
> be written to analyze the Vim runtime for possible commands?
It's been a while since I've spelunked in the source, but I seem to
remember much of the base set of actions and motions were
table-driven (though through mappings this can be overridden), so it
wouldn't be too hard to convert that into some sort of GraphViz input
file.
-tim
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Tuesday, November 26, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment