vimwiki style links without vimwiki?

hyperlink, vim, vim-plugin

Solution

I think you could just write one for your simple use case, something like:

function! LinkForward()
    let g:fromFile=expand('%:p')
    let fn= substitute(getline('.'),'^.*\[\[\([^\]]*\)\].*$',"\\1",'g')
    execute "e ".fn
endfunction

nnoremap <cr> :call LinkForward()<cr>

function! LinkBackward()
    execute "e ".g:fromFile
endf

nnoremap <bs> :call LinkBackward()<cr>

source this will do some similiar action, e.g pressing `Enter` on `[[path/to/file/foo]]foo` will go to that `foo` file, and within that file pressing `<Backspace>` will get you back.

note the codes above are just example, it won't work perfect. You could make it work better, e.g:

- add a list/(stack) to store the file jump history.

- define that this kind of action works only for certain filetype

- check if the line under cursor doesn't match `[[...]]` then do normal `<Enter>`

- etc.. if you like you could take a look vimwiki's codes and "borrow" some snippets for your personal usage.

hope it helps you.. & good luck.

Problem

One of my favorite features of vimwiki is the way it handles links. Unfortunately, I use something else (vimoutliner) for my main note-taking, and it doesn't have anywhere near the linking capability that vimwiki does. Is there a plugin that adds the linking functionality of vimwiki (or at least something similar) when editing any arbitrary file, and not just a *.wiki file?

Original source