Skip to content

tuffy/vle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

819 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Very Little Editor

The Very Little Editor, or VLE, is a small text editor with just enough features to do some actual work.

Modern full-featured text editors can be a little daunting, complete with dozens upon dozens of different commands to remember and modes to switch between. It's a lot of power, but that power comes with the cognative load of having to remember which key combination to use or what mode the editor is in at any given time.

Let's try a different approach and see just how few features we need. By restricting our feature set to less than twenty powerful features, we can devote more mental effort to our projects and less mental effort to our tools.

VLE Screen Capture

Installation

Installing VLE from source can be done using Cargo:

cargo install vle

VLE compiles to a single self-contained binary which contains everything. Its syntax highlighting for different languages are built-in and it uses no configuration file; its minimal configuration options are done via simple environment variables.

Keybindings

Action Shortcut Shortcut
Toggle Keybindings Display F1
Open File F2 Ctrl-O
Save File F3 Ctrl-S
Goto Line or Bookmark F4 Ctrl-T
Find Text in File or Selection F5 Ctrl-F
Update Selected Lines F6 Ctrl-U
Goto Matching Pair F7 Ctrl-P
Select Inside Pair F8 Ctrl-E
Select Word or Whole Lines F9 Ctrl-W
Handle Pane Splits F10 Ctrl-N
Reload File F11 Ctrl-L
Quit File F12 Ctrl-Q
Toggle Bookmark Ins Ctrl-B
Highlight Text Shift-Arrows
Set Mark Ctrl-Space
Start of Selection Ctrl-Home
End of Selection Ctrl-End
Indent or Autocomplete Tab
Cut Ctrl-X
Copy Ctrl-C
Paste Ctrl-V
Undo Ctrl-Z
Redo Ctrl-Y
Switch Pane Ctrl-Arrows
Previous Buffer Ctrl-PgUp
Next Buffer Ctrl-PgDn
Manage Buffers Ctrl-]

Because we have so few features, non-navigational features have alternative Ctrl-based and F-based keybindings. This also helps maintain compatibility with terminal multiplexers which have many of their own dedicated Ctrl bindings.

Key Features

Multi Cursor-Style Find and Replace

Ctrl-F / F5 to find text will highlight all matches and move your cursor to the next available match, if any. Matches can be cycled between using the up and down arrow keys. This much is unremarkable.

However, you may also edit found matches simply by typing in new text, which overwrites the located matches, or by using the left and right arrow keys to reposition cursors within all matches to make partial edits.

Multi-Item Replace Demonstration

Additionally, for regular-expression based searches, captured groups can be pasted to all matches simultaneously.

Regular Expression Replacement Demonstration

Multi Cursor-Style Line Editing

Similar to find-and-replace, you can simply highlight a selection of lines and use Ctrl-U / F6 to edit each of them simultaneously as a unit.

Multi-Line Edit Demonstration

Multi Cursor-Style Copy and Paste

When multiple items are selected, they can also be cut/copied as a unit. They can then be pasted individually, in order, or pasted as a unit to another multi-item selection.

Multi-Item Copy and Paste Demonstration

Bookmarks

Have a spot in your file you'd like to mark and return to later? Place bookmarks with Ctrl-B / Insert, which drops visible positions in the text that remain fixed in place. Ctrl-T / F4 doubles as both a way to jump to a specific line and also a means to cycle between bookmarks using the arrow keys.

Bookmarks can be removed either by Ctrl-B / Insert on the same position, or simply by erasing the text containing the bookmark. Hando for TODO items which are no longer needed.

Bookmarks

Split Pane Views

The editor's viewport can be split into vertical or horizontal panes using Ctrl-N / F10. Each pane can contain a different file, or different spots within the same file. Switch between them using Ctrl-Arrows. Ctrl-N / F10 can split panes recursively into more sub-panes, delete existing panes, or adjust the pane size ratios.

Multiple Panes Demonstration

Configuration

With very little to configure, VLE doesn't use a config file at all. Any configuration is performed with a modest number of environmental variables:

Variable Default Meaning
VLE_SPACES_PER_TAB 4 number of spaces to output per tab
VLE_ALWAYS_TAB 0 whether to always insert literal tabs
VLE_PAGE_SIZE 25 number of lines PgUp and PgDn move
VLE_EXT_MAP empty syntax highlighting extension mapping

No config file means there's one less thing to install, learn the format of, modify or break.

Extension Mapping

Syntax highlighting is determined by a file's extension. If you have files with some non-standard extension, the VLE_EXT_MAP environmental variable can map them from one to another. Its syntax is a comma-separated list of src=target key-value pairs. For example, if one has a file.tpl that's should be highlighted as HTML, try:

VLE_EXT_MAP=tpl=html vle file.tpl

ZelliJ and tmux Integration

When Ctrl-Arrows are used to navigate panes, VLE normally stops when it cannot proceed further in any direction. When running under ZelliJ or tmux, the editor will issue a zellij or tmux command to change focus out of the VLE's pane in the given direction.

Furthermore, the Fish's keybindings can be updated to also use Ctrl-Arrows to navigate ZelliJ or tmux. Simply add the corresponding bindings to your ~/.config/fish/config.fish file:

if set -q ZELLIJ
    bind ctrl-left "zellij action move-focus left"
    bind ctrl-right "zellij action move-focus right"
    bind ctrl-up "zellij action move-focus up"
    bind ctrl-down "zellij action move-focus down"
else if set -q TMUX
    bind ctrl-left "tmux select-pane -L"
    bind ctrl-right "tmux select-pane -R"
    bind ctrl-up "tmux select-pane -U"
    bind ctrl-down "tmux select-pane -D"
end

This allows one to navigate from the editor to a nearby shell, and the reverse, for a seamless integration between the two.

Why Another Editor?

I've tried a lot of different text editors over the years, all with their own strengths and weaknesses. But I could never find the exact text editor I was looking for. Some were a little too overcomplicated. Some were a little too primitive. So rather than continue a seemingly endless search for the exact right text editor for me, I decided to write my own by mixing necessary features (like file saving) and those that impressed me in other editors (like splitting panes or selecting inside quotes).

Whether it's the editor for you depends on your needs and tastes. But VLE has been developed exclusively with itself since version 0.2, so I can confidently say that it's good enough for projects at least as large as itself.

About

Very Little Editor

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages