[TUHS] diving into vi (nvi) - some observations from a slow learner

Ralph Corderoy ralph at inputplus.co.uk
Sat Jun 8 01:41:20 AEST 2024


Hi Will,

> But, I think I'll stick with nvi a while until I really nail it down.

Something I used to do was to look at each key on the keyboard and think
what it would do, e.g. d, D, and ^D.  Most do at least one thing.

> Leftward motions - [[, {, (, 0, ^|_, B, b, h|^H
> Rightward Movement - l|SP, e, E, w, W, $, ), }, ]]

You're missing these handy six: f F t T ; ,

> Upward motions - 1G, ^B, H, ^U, -, k | ^P
> Downward motions - G, ^F, L, ^D, ^M | +, j | ^J | ^N

There's also keeping the cursor on the same line but moving the window
over the text: z ^E ^Y

> Off to figure out tags

Understand the format of the tags file first; built by ctags(1).
^] on a word looks it up and goes there.
Where you were is pushed on to the ‘tagstack’.
When you wish to exit that rabbit hole, ^T pops the top of the stack and
goes there which returns you to where you pressed ^].

    $ func='foo bar xyzzy'
    $ printf "%s: $func"'\n' $func >src
    $ cat src
    foo: foo bar xyzzy
    bar: foo bar xyzzy
    xyzzy: foo bar xyzzy
    $ grep -n '[^:]*' src | awk -F: '{print $2 "\tsrc\t" $1}' >tags
    $ sed -n l tags
    foo\tsrc\t1$
    bar\tsrc\t2$
    xyzzy\tsrc\t3$
    $

vi src, move to a word, ^] and it will move you to the ‘definition’
line.  Imagine each line is a function definition with calls to other
functions.  You're wandering down and up a ‘call tree’, following
possible execution paths.

-- 
Cheers, Ralph.


More information about the TUHS mailing list