Blame


1 ddc03123 2020-03-28 op UNIX is all about files and programs that do one thing and to it well,
2 ddc03123 2020-03-28 op right? `vi(1)` is one of my favorite text editors. However it lacks
3 ddc03123 2020-03-28 op some feature: but here's where the *composition* shines.
4 ddc03123 2020-03-28 op
5 ddc03123 2020-03-28 op It's stupid and dead-simple actually, but I haven't thought
6 ddc03123 2020-03-28 op about it until some weeks ago. With a simple
7 ddc03123 2020-03-28 op
8 a3ab6f61 2020-09-22 op ```vi
9 a3ab6f61 2020-09-22 op map « :w^M:!aspell -c %^M:e!^M^M
10 a3ab6f61 2020-09-22 op ```
11 ddc03123 2020-03-28 op
12 ddc03123 2020-03-28 op in your `~/.nexrc` it's simple to do spell checking in `vi`.
13 ddc03123 2020-03-28 op
14 ddc03123 2020-03-28 op **Friendly remainder**: the `^M` is literally the *enter* key inserted
15 ddc03123 2020-03-28 op with `C-v ENTER` or `C-v C-m`.
16 ddc03123 2020-03-28 op
17 ddc03123 2020-03-28 op I've also the following binding in my `~/.nexrc` to spell check
18 ddc03123 2020-03-28 op Italian text:
19 ddc03123 2020-03-28 op
20 a3ab6f61 2020-09-22 op ```vi
21 a3ab6f61 2020-09-22 op map » :w^M:!aspell --lang=it -c %^M:e!^M^M
22 a3ab6f61 2020-09-22 op ```
23 ddc03123 2020-03-28 op
24 ddc03123 2020-03-28 op ### What's that gibberish?
25 ddc03123 2020-03-28 op
26 ddc03123 2020-03-28 op OK, it may be non-obvious what that that mapping does, so let's split
27 ddc03123 2020-03-28 op it into pieces:
28 ddc03123 2020-03-28 op
29 ddc03123 2020-03-28 op - `map «` starts a mapping on the `«` key
30 ddc03123 2020-03-28 op - `:w^M` writes the current file (the return is necessary to *enter* the command)
31 ddc03123 2020-03-28 op - `:!aspell -c %^M` run aspell over the file (`%` is replaced with the current file name)
32 ddc03123 2020-03-28 op - `:e!^M` force vi to re-read the file
33 ddc03123 2020-03-28 op - `^M` Tell vi to render the editor. After a command execution vi doesn't render its interface. Rather, it wait (a bit like `ex`) for a command.
34 ddc03123 2020-03-28 op
35 ddc03123 2020-03-28 op ### Why the `«` and `»` characters?
36 ddc03123 2020-03-28 op
37 ddc03123 2020-03-28 op Those keys aren't bind to anything and are simple to type with my keyboard layout.