💾 Archived View for gemini.susa.net › Vim › vim_faq_command_line.gmi captured on 2022-07-16 at 13:42:29. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

Vim FAQ from the command line

One of the first things I wrote in Gemini was a cgi script to grep bits from the Vim FAQ.

Now, thanks to Drew DeVault's little line-mode client, it's really useable from any of my command lines.

I created a one-liner script in my local bin directory:

kevin@kakapo:~$ cat bin/vim-faq
#!/bin/bash

gmnlm "gemini://gemini.susa.net/cgi-bin/vim-search?${1}"

So when I type, for example, 'vim-faq cursor', I get:

kevin@kakapo:~$ vim-faq cursor
#  Search results for: cursor
0) Question: 5.7
         How do I edit a file whose name is under the cursor?

1) Question: 10.2
         In insert mode, when I press the <Esc> key to go to command mode, the
        cursor moves one character to the left (except when the cursor is on
        the first character of the line). Is it possible to change this
        behavior to keep the cursor at the same column?

2) Question: 10.3

... etc.

Then I can just select the FAQ entry to view. It's item zero I was looking for, so:

[Enter]: read more; [N]: follow Nth link; [q]uit; [?]; or type a URL
(more) => 0
#  You requested the FAQ entry 5.7
   Q: 5.7. How do I edit a file whose name is under the cursor?

   Answer
   ------
   You can use the gf command to edit a file whose name is under the cursor.
   You can use the CTRL-W f command to edit the file in a new window and
   finally you can use CTRL-W gf top open a new tab page that contains the
   file name under the cursor.

   For more information, read

       gf
       CTRL-W_f
       CTRL-W_gf
       'isfname'
       'path'
       'suffixesadd'
       'includeexpr'


0) Search for something else.

That is genuinely useful to me, since I spend so much time in the shell.

I think it's a great example of centralised data accessed by simple accessible tools. The fact that Drew's code carries no complex dependencies means I can have this utility pretty much anywhere with very little effort.