Message Boards Message Boards

Vilfram: Vi-like editing for Wolfram Notebooks

Posted 1 year ago

Screenshot of Vilfram example

Hey everyone, I'm excited to announce the MVP release of ConnorGray/Vilfram, a new paclet I've been working on that adds a Vi-like editing experience to Wolfram Notebooks.

This is just a short post to get the word out to anyone who might be interested in trying it out.

More details can be found in the Vilfram GitHub repository:

>> https://github.com/ConnorGray/Vilfram <<

Getting Started

The ConnorGray/Vilfram paclet can be installed from paclets.com by evaluating:

PacletInstall["ConnorGray/Vilfram"]

Once installed, Vilfram will automatically be available and enabled in any opened notebook.

Check the section "Disabling Vilfram" below for instructions of disabling Vilfram.

Examples

Use h, j, k, and l keys for basic movement:

enter image description here

Switch between Insert and Command mode:

enter image description here

Use $, ^, e, and b to jump to the beginning and end of lines and words

enter image description here

Use visual selection to quickly copy, cut, and delete

enter image description here

Smart selection expansion to efficiently select the right subexpression

enter image description here

All Supported Commands

The following Command-mode sequences are supported:

Mode switching

  • i, a — enter Insert mode
  • Esc — enter Command mode

Movement

Character-oriented:

  • h — move single character left
  • l — move single character right
  • j — move single line down
  • k — move single line up

Word-oriented:

  • e — move to next word
  • b — move to previous word

Line-oriented:

  • ^ — move to beginning of line
  • $ — move to end of line
  • o — insert new line below
  • O — insert new line above

Document-oriented:

  • G — move to top of notebook
  • gg — move to end of notebook

Visual Selection

  • v — begin visual selection
  • h — change selection single character left
  • l — change selection single character right
  • j — change selection single line down
  • k — change selection single line up
  • e — extend selection to next word
  • b — extend selection to previous word
  • ^ — extend selection to beginning of line
  • $ — extend selection to end of line
  • y — copy ("yank") current selection
  • x — cut current selection

Deletion

  • de — delete to next word
  • db — delete to previous word
  • d^ — delete to beginning of line
  • d$ — delete to end of line

Other

  • u — undo
  • :w — save current notebook
  • :x — save and close current notebook

Notable differences from Vi

Wolfram Notebooks are different in structure and supported functionality from traditional character-based editors. Some Vi commands have Vilfram analogues with slightly different behavior that is better suited to the features of the notebook environment.

  • Structured selection commands

Notebooks support a powerful and intuitive structural selection mechanism whereby the current selection can be expanded in steps that are each an enclosing syntactical structure.

  • vi — expands the selection each time i is pressed
  • di+ — expands the selection each time i is pressed; deletes when the Return key is pressed
  • No block caret

Vi often distinguishes between Insert and Command mode by, respectively, changing the input caret between a block which is placed on a particular character, and a vertical bar which is placed in-between characters.

Disabling Vilfram

"Help! I installed Vilfram and now I'm stuck!"

Don't panic. You're not the first to get stuck in Vi.

To disable Vilfram, use your mouse to select the Edit > Disable Vilfram menu item:

enter image description here

This will persistently disable Vilfram in the current and future sessions.

Use Edit > Enable Vilfram to re-enable Vilfram.

Enjoy!

Connor

POSTED BY: Connor Gray
5 Replies

Interesting...

  • Although, it is little bit like giving a drink to an alcoholic.

    • (Some people really cannot quit their vi addiction.)
  • Should we expect a "Vimfram" version (for vim)?

  • Any plans for "Emacsatematica"?

POSTED BY: Anton Antonov

No Vimfram version is currently planned, but my understanding of the distinction is that Vim doesn't change the key bindings much, it just adds things like syntax highlighting and plugin support.

I'm also not a huge fan of Emacs keybindings, so no Emacsatematica is planned, at least from not from me ;)

POSTED BY: Connor Gray

Thank you for your reply! I was obviously trolling (someone who obviously likes vi, at least a little...)

POSTED BY: Anton Antonov

enter image description here -- you have earned Featured Contributor Badge enter image description here Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: Moderation Team

5-15-23 Connor - congratulations!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract