Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Construct a graph of simple Vim-style movements in text
ResourceFunction["VimGraph"][text] returns a graph with letters as vertices and Vim-style movements as edges. |
| Shortcut | Movement Description |
| h / l | Move one character left / right on the same line |
| k / j | Move one character up / down; jumps to end of target line if shorter than current horizontal position |
| w / b | Jump to the beginning of the next / previous word, across lines |
| e | Jump to the end of the next word, across lines |
| ^/$ | Move to the beginning/end of the current line |
Vim graph for the movements: up, right, and to the beginning of the next word, respectively:
| In[1]:= |
| Out[1]= | ![]() |
The same, with nicer formatting:
| In[2]:= | ![]() |
| Out[2]= | ![]() |
Returns a minimal sequence of keystrokes needed to move from one letter to another:
| In[3]:= | ![]() |
| Out[3]= | ![]() |
Illustrates the relationship between the maximum keystroke distance required to navigate between two letters in a text and the number of randomly inserted newlines:
| In[4]:= | ![]() |
| Out[4]= | ![]() |
Use the "CustomPatterns" option to define new movements by passing a string pattern to "StringPattern", with optional shortcuts for jumping forward or backward to the nearest match:
| In[5]:= | ![]() |
| Out[5]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License