Basic Examples (2)
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]= |
|
Scope (3)
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]= |
|
.png)

![ResourceFunction["VimGraph"]["How do\nI exit Vim?", "IncludedVimMovements" -> {"k", "l", "w"}, VertexSize -> Large, VertexStyle -> LightYellow, VertexLabelStyle -> Directive[Bold, Large], EdgeLabels -> "EdgeTag", EdgeLabelStyle -> Directive[Bold, Orange, Medium]]](https://www.wolframcloud.com/obj/resourcesystem/images/246/24658b8d-b372-4615-bde0-45af1083ecc9/668f4f50b67be31d.png)

![With[{g = ResourceFunction["VimGraph"][
"Chuck Norris\nwrites his DNA\n in Vim. In\nNormal mode."]}, HighlightGraph[g, Subgraph[g, FindShortestPath[g, {1, 1}, {4, 10}]], EdgeLabels -> "EdgeTag", EdgeLabelStyle -> Directive[Bold, Large]]]](https://www.wolframcloud.com/obj/resourcesystem/images/246/24658b8d-b372-4615-bde0-45af1083ecc9/3aab963d9b0416fc.png)

![BarChart[
Table[Mean[
Table[GraphDiameter[
ResourceFunction["VimGraph"][
StringInsert[#, "\n", RandomSample[Range[StringLength[#]], n]] & @
StringTake[ExampleData[{"Text", "DeclarationOfIndependence"}], 200]]], {m, 1, 10}]], {n, 1, 20}]]](https://www.wolframcloud.com/obj/resourcesystem/images/246/24658b8d-b372-4615-bde0-45af1083ecc9/06618ed000c3271b.png)

![ResourceFunction[
"VimGraph"]["How is your\n mode today?\nNormal mode\nInsert mode\nNormal mode\nVisual mode\nInsert mode", "IncludedVimMovements" -> {}, "CustomPatterns" -> {
<|"StringPattern" -> "Normal", "Forward" -> "n", "Backward" -> "N"|>,
<|"StringPattern" -> "Insert", "Forward" -> "i"|>,
<|"StringPattern" -> "Visual", "Backward" -> "V"|>} ,
VertexSize -> Large, VertexStyle -> LightYellow, VertexLabelStyle -> Directive[Bold, Medium], EdgeLabels -> "EdgeTag",
EdgeLabelStyle -> Directive[Bold, Orange, Medium]]](https://www.wolframcloud.com/obj/resourcesystem/images/246/24658b8d-b372-4615-bde0-45af1083ecc9/1c0699b7a76e8216.png)

