vle 1.19.3

Very Little Editor - an exercise in minimalist text editing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
__     __                _     _ _   _   _        _____    _ _ _
\ \   / /__ _ __ _   _  | |   (_) |_| |_| | ___  | ____|__| (_) |_ ___  _ __
 \ \ / / _ \ '__| | | | | |   | | __| __| |/ _ \ |  _| / _` | | __/ _ \| '__|
  \ V /  __/ |  | |_| | | |___| | |_| |_| |  __/ | |__| (_) | | || (_) | |
   \_/ \___|_|   \__, | |_____|_|\__|\__|_|\___| |_____\__,_|_|\__\___/|_|
                 |___/

                  - An Exercise in Minimalist Text Editing -

Version: VERSION

Press the F1 key to see a list of keybindings.

# About The Very Little Editor

Inspired by GNU Nano and other minimalist editors, this editor is designed
to provide a small but powerful set of features taken from all the text
editors I've ever used over the years.

# Tutorial

## Navigation

The Very Little Editor, or VLE for short, is non-modal in the
sense that it doesn't have seperate modes for typing text
and issuing commands to edit text.

This means we use the arrow keys (← ↓ ↑ →) along with
PgUp, PgDn, Home and End to move the cursor around.
The arrows move the cursor one character at a time in
the indicated direction. PgUp and PgDn move the cursor
up and down several rows, respectively. And lastly,
Home and End move the cursor to the beginning and end of the
line, respectively.

As you move the cursor downward, you'll notice the viewport
shifts text as needed so as to always keep it centered vertically.
This makes it easy for your eyes to locate it,
and eliminates the need for separate keys to adjust the
viewport's position around your cursor.


## Inserting Text

Inserting text is as simple as typing it in.
Try moving your cursor to line marked with '>>>',
hit the End key to place it at the end of the line if necessary,
and then type in the remaining text to match the line below it.

>>> sphinx of black quartz
    sphinx of black quartz judge my vow


## Deleting Text

Removing text is accomplished with the Backspace and Del
keys. Backspace removes one character to the left
of the cursor, while Del removes one character to the right.

In this first example, move your cursor to the line marked
with '>>>', use the End key to place your cursor at the end
of the line, and then repeatedly Backspace until
it matches the line below it.

>>> A sentence that's just about perfect except for this extra text
    A sentence that's just about perfect

In this second example, move your cursor just past the '>>>'
marker, and then repeatedly Del until it matches the line below it.

>>> Extraneous junk. This sentence is just right.
    This sentence is just right.


## Saving Your File

As you've made changes to this buffer, you'll notice an
asterisk (*) next to its title at the top. This indicates
the buffer has unsaved changes. Ctrl-S/F3 saves the current file.
Go ahead and try it now (this tutorial buffer is special
and isn't actually written to disk, but will behave as if it was).
Once saved, the asterisk will disappear until the next change is made.


## Selecting Text

Highlight text by holding down the Shift key along with a direction key.
Or, one can use Ctrl-Space to place a mark in the text and
highlight text by using the direction keys.
Once text is highlighted, you may copy it with Ctrl-C
(which leaves the text in place), cut it with Ctrl-X
(which removes it from the text), and then paste it with Ctrl-V.

Try using copy-and-paste to fix the line below.

>>> Duplicate sentence.
    Duplicate sentence. Duplicate sentence.

And use cut-and-paste to reorder the sentences in the line below.

>>> Sentence 2. Sentence 1.
    Sentence 1. Sentence 2.

If a selection is active, pasting will swap the contents of
the cut buffer and pasted region.


## Navigating a Selection

While a selection is active, Ctrl-Home and Ctrl-End
will place the cursor at its beginning or end, respectively.
This may be especially handy when the selection has gotten
quite long or needs to be extended from one side or another.


## Autocompleting Text

If the cursor is located just past the end of a word,
the Tab key will attempt to auto-complete that word.

For example, try moving your cursor to the end of the word "pneu",
and then hit Tab to fill in the rest.

>>> pneu
    pneumonoultramicroscopicsilicovolcanoconiosis

Repeatedly pressing Tab will cycle through all possible
candidates, from most common to least, before returning
back to the beginning.

Similarly, Shift-Tab will autocomplete in reverse order
from least common to most (which may be helpful if one
happens to hit Tab one time too many).


## Indenting Text

Using Tab anywhere outside the end of the word
will indent that line, which inserts four spaces by default.
If a selection is active or multiple lines are selected,
all lines will be indented simultaneously.

Similarly, Shift-Tab will un-indent the current
or selected lines by the same number of spaces.
This will only work if the whole region can be
un-indented as a unit; once any line of text
cannot be un-indented further, un-indenting will stop.

The number of spaces inserted per tab is controlled
with the VLE_SPACES_PER_TAB environment variable,
which can be modified from your shell prior to running VLE.

Similarly, if one wants to have the Tab key insert
literal tabs for all file formats (and not just Makefiles),
that can be configured by setting the VLE_ALWAYS_TAB
environment variable to something.

Let's give it a try with an example:

fn my_function_name(a: i32, b: i32, c: i32) {
println!("a is {a}");
println!("b is {b}");
println!("c is {c}");
}


## Editing Multiple Lines Simultaneously

Similar to indenting text, highlighting a selection
and using Ctrl-U/F6 will allow one to edit all the lines
of that selection simultaneously.
This allows one to comment or un-comment multiple
lines as a unit, among other things.

For example, let's comment out six lines of placeholder text:

>>> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
>>> Nullam viverra est nec sem feugiat blandit.
>>> Vestibulum ante ipsum primis in faucibus orci luctus et
>>> ultrices posuere cubilia curae;
>>> Phasellus consequat massa lorem, vel cursus enim tristique vel.
>>> Nunc dictum imperdiet porttitor.
    # Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    # Nullam viverra est nec sem feugiat blandit.
    # Vestibulum ante ipsum primis in faucibus orci luctus et
    # ultrices posuere cubilia curae;
    # Phasellus consequat massa lorem, vel cursus enim tristique vel.
    # Nunc dictum imperdiet porttitor.



## Surrounded Text

Text surrounded by characters like " or ( are a common
occurence in programming, so this editor provides a
handy "enveloped items" mode for dealing with it.

When no selection is active, Ctrl-E/F8 will attempt
to select inside of text surrounded by pairs.

Once a selection is active, we can cut or copy it
like any other selection. Or, we may even simply
start typing new text to delete the selection and replace
it with what we've typed.

Try moving your cursor somewhere inside the long string
(it doesn't matter where), then hit Ctrl-E/F8.
Once the selection is active, type in the string
we want instead.

>>> "a long string we would rather delete and replace"
    "the correct string"


Typing Ctrl-E/F8 multiple times will expand outward
from inner nested values, to the paired characters themselves,
and then to the next pair of enclosing characters.

>>> { "try Ctrl-E/F8 thrice in this area then type new text" }
    {new text}


If it can't figure out which pair of characters you mean,
it will prompt for which ones to expand into.

>>> { ( [ try Ctrl-E/F8 here, then the curly bracket key ) ] }
    {fixed text}


If a selection is active, typing a surround character
like ( will add the appropriate pair on each side
of the selection while keeping the selection active.

Try highlighting the text below,
then type ( to surround it with parentheses.

>>> surround me
    (surround me)


Lastly, if a selection is active,
Del will delete the appropriate pair
of surrounding characters on each side of the selection.
This allows us to quickly strip off an unwanted
set of surrounding characters.

Try moving your cursor inside the parenthesized text
(again, it doesn't matter where),
then use Ctrl-E/F8 to select inside the parentheses.
Finally, Del will delete the surrounding parentheses.
All in far fewer keystrokes than trying to navigate
and delete them one at a time.

>>> (un-surround this text)
    un-surround this text


## Undoing and Redoing Changes

Sometimes we make some mistakes when entering text.
Ctrl-Z restores the buffer and cursor to its previous state.
Use Ctrl-Z repeatedly to go further back as needed.
This editor's undo stack has no limit, so you may return
all the way back to how the file was when it was first
opened, if necessary.

If you wind up going backward too far, Ctrl-Y performs
a redo, undoing the undo you just made. So long as
no new changes have been made, you can always redo your
way back to the buffer's state before you undid anything.


## Navigating to a Line

Often, you'll find you've made an error at a specific line
in a file. Ctrl-T/F4 brings up a prompt asking for which
line you'd like to go to. Going to line 274 will bring
you to the beginning of this section.

In addition, you may use Home and End within the "goto line"
prompt to jump to the beginning and end of the file, respectively.


## Navigating to a Matching Pair

Sometimes you'll find your cursor is at one end of a
matching pair of things, and you'd like to navigate
to the other end without counting all the intervening
opening and ending characters by hand. This is where
Ctrl-P/F7 comes in handy.

Try placing your cursor at the starting { and
use Ctrl-P/F7 to jump all the way to the end.
From there, you're free to use Ctrl-P/F7 to jump
all the way back to its matching opening character
at the beginning.

{
  "item": {
    "children": [
      {"name": "Child A"},
      {"name": "Child B"},
      {"name": "Child C"}
    ],
  }
}

Note that this only works for matching pairs which
point in specific directions; it's not available
for pairs like " because we have no way to know which
direction to go.


## Finding Text

Sometimes we want to locate text in a file
but don't know exactly which line it's on.
Ctrl-F/F5 prompts for text to search for.

Once you've entered the text you need,
Enter will highlight all matches (if any)
and move your cursor to the first one so you
may browse or edit them all.

If text has already been highlighted,
Ctrl-F/F5 will locate all instances of that text
and jump directly to browse/edit mode.
This may be more convenient than typing it in by hand.

Found items are highlighted by default.
Entering new text will zap the current selections
and enter new text, just as in regular editing mode.

Let's walk through this whole process.

Start with Ctrl-F/F5 to find the first instance of the word to replace.
This will highlight all three instances of that word, below.

Then type "fixed" to replace all three instances
and hit Enter when finished.

>>> toreplace
>>> toreplace
>>> toreplace
    fixed


## Regular Expressions

Finding and replacing text also supports regular expressions,
which are available by pressing Tab after entering find mode
with Ctrl-F/F5.

This allows for searching text via regular expression patterns,
which are more expressive than plain text searches.

Additionally, replacing regular expression matches allows
for pasting captured groups interactively.

Let's walk through an example of some mis-ordered
comma-separated values.

Type Ctrl-F/F5 and then Tab to enter regular expression find mode.

Then type

([0-9]+),([0-9]+)

followed by Enter to find our comma-separated numbers
and capture them in two groups.

Ctrl-V followed by 2 followed by a , will zap the current selections
and place the second column first.

Finally, Ctrl-V followed by 1 will place the first column last.

>>> 2222,1111
>>> 44,333333
>>> 66666,555
>>> 8,7777777


## Multi-Item Cut, Copy and Paste

When multiple items are selected, they can also be cut or copied into
separate cut buffers.  Let's highlight the following ten lines:

ONE
TWO
THREE
FOUR
FIVE
SIX
SEVEN
EIGHT
NINE
TEN

Use Ctrl-U/F6 to edit each of those lines individually,
then Ctrl-W/F9 to select whole lines,
then Ctrl-C to copy all ten separately,
and finally Enter to complete our multi-item selection.

We can then paste those items individually using Ctrl-V,
which cycles through all ten before returning to the first.

>>> ZERO
    ZERO ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN

We'll then follow with a plaintext search (Ctrl-F/F5) for double X.
Using Ctrl-V to paste will populate all ten matches with the ten items
we previously copied, in order.

>>> const XX   = 1; const XX   = 2;
>>> const XX = 3; const XX  = 4;
>>> const XX  = 5; const XX   = 6;
>>> const XX = 7; const XX = 8;
>>> const XX  = 9; const XX  = 10;

These are helpful way to copy and paste many things at once.


## Bookmarks

Bookmarks provide a way to mark spots in a file
with the intent of returning to them later.
Ctrl-B/Insert toggles a bookmark's location,
inserting one if not present or removing it if present.

The total number of bookmarks present is indicated
in the file's status bar in the upper right hand corner.

Bookmarks can be navigated between using Ctrl-T/F4
(the same mode using for going to a particular line)
and cycled between using ↑ and ↓.

Deleting text under a bookmark will also delete the bookmark itself,
which may be helpful when bookmarks are attached to TODO items
within a piece of code and are no longer required.


## Multiple Buffers

We've been working entirely within the tutorial buffer thus far.
However, we may want to work with multiple files at the same time.
Ctrl-O/F2 goes into an "open file" mode which allows us to
navigate to an existing file on disk or provide a filename
for a new file to create. Each file is opened into its own buffer.

Buffers can be cycled using Ctrl-PgUp and Ctrl-PgDn.
Or, Ctrl-] opens a buffer selection menu which allows
selecting a buffer from a list interactively.
The buffer's filename will be indicated in its title
on the upper left.

Unneeded buffers can be closed using Ctrl-Q/F12, and the editor
will exit once the final buffer is closed.


## Panes

It's often handy to see multiple buffers open side-by-side
simultaneously - or even two different places in the same buffer.
This is where the panes feature comes in handy.

Ctrl-N/F10 prompts for how one wishes to split a single pane in two.
← or → divides a single window into two tall side-by-side sections
which we can navigate between using Ctrl-← and Ctrl-→.

Alternatively, Ctrl-N/F10 and then ↑ or ↓ divides a single window
into two wide top-and-bottom sections which we can navigate between using
Ctrl-↑ or Ctrl-↓.

Ctrl-N/F10 followed by Del deletes the current pane,
but does not affect the pane's open buffers which remain
available on the remaining panes.

Panes can be subdivided recursively as needed,
each getting a 50/50 split of the remaining space.


# Closing Thoughts

As the name suggests, this is a Very Little Editor that doesn't
have a mountain of features or require a lengthy tutorial to operate.
But if you've reached this point, hopefully you'll have a better
understanding of how and why it operates beyond just the
keybindings themselves.

If it's not the editor for you, that's perfectly okay.
There's plenty of other great text editors in the world
and one of them is bound to be for you.

And if you still can't find an editor you like,
feel free to follow my example and write one that has
all the features that you do like.