Skip to content

Commit

Permalink
vim: find wiki backlinks
Browse files Browse the repository at this point in the history
This code uses some clever filename expansion: we expand to a full path
with :p, then substitute off whatever g:wiki_root is with :s?pat?repl?
and an empty replacement. This will break if your g:wiki_root has a ? or
pattern metacharacters, though :/ Finally, we lop off the leading slash
from absolute paths.

The search will also break if the filename has metacharactes in it for
:grep, which for me is rg at the moment.
  • Loading branch information
benknoble committed Oct 19, 2024
1 parent a3f1532 commit 9c17e48
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions links/vim/after/plugin/config/wiki.vim
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ call popsikey#register('<Leader>w', [
\ info: 'edit notepad',
\ action: ":Ewiki notepad\<CR>",
\ },
\ #{
\ key: 'b',
\ info: 'find backlinks',
\ action: ":execute 'grep' expand('%:p:s?' .. g:wiki_root .. '??')[1:] g:wiki_root\<CR>",
\ },
\ ],
\ #{
\ title: ' Wiki ',
Expand Down

0 comments on commit 9c17e48

Please sign in to comment.