The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Ralph Corderoy <ralph@inputplus.co.uk>
To: TUHS <tuhs@tuhs.org>
Subject: [TUHS] Re: diving into vi (nvi) - some observations from a slow learner
Date: Fri, 07 Jun 2024 16:41:20 +0100	[thread overview]
Message-ID: <20240607154120.08031210F3@orac.inputplus.co.uk> (raw)
In-Reply-To: <a79c56d0-c198-4496-a153-0be900519137@gmail.com>

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.

  reply	other threads:[~2024-06-07 15:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 14:44 [TUHS] " Will Senn
2024-06-07 15:41 ` Ralph Corderoy [this message]
2024-06-07 16:20   ` [TUHS] " Will Senn
2024-06-07 16:58     ` Andy Kosela
2024-06-07 17:29 ` Marc Rochkind
2024-06-08  4:44   ` Dave Horsfall
2024-06-08  4:50     ` Warner Losh
2024-06-08  6:22       ` Rob Pike
2024-06-07 22:12 ` Scot Jenkins via TUHS
2024-06-08 10:19   ` [TUHS] POSIX ed(1)'s exit status. (Was: diving into vi...) Ralph Corderoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240607154120.08031210F3@orac.inputplus.co.uk \
    --to=ralph@inputplus.co.uk \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).