opening text file links in terminal vim?

582 views
Skip to first unread message

ccahua

unread,
Jan 12, 2013, 6:58:45 PM1/12/13
to vim...@googlegroups.com
Hi,

I'm really enjoying VimWiki but cannot get local text files to open in vim running from terminal.

It's about the only thing keeping me from moving off emacs org-mode w/ deft

I only have vimwiki and calendar as plugins running on vim 7.3

I'm getting the same issue as https://code.google.com/p/vimwiki/issues/detail?id=386 where the screen goes blank and recovers on ctrl-l

but I'm not sure how to fix it with that solution from the poster: call system('xdg-open ' . shellescape(a:url) . ' &')

Do I edit vimwiki.vim?

Do I have to mess with the VimWikiLinkHandler?

The issue occurs with Vimwiki 2.01 stu on both Win7 cygwin and Mac OS X

a workaround is to use :e file with :buffers but it kinda defeats the purpose of linking to external links

Depending on the link type tested,
file link:
[[vlocal:~/notes/life.org]]
[[/Users/<username>/notes/life.org]]
[[local:~/notes/life.org]]
[[../notes/life.org]]
[[file:///../notes/life.org]]
[[file:///Users/<username>/notes/life.org]]

I get different output when I let g:vimwiki_debug = 3

open_link: idx=0, scheme=wiki0, path=/Users/<username>/vimwiki/, subdir=, lnk=/Users/<username>/notes/life.org, ext=.wiki, url=/Users/<username>/vimwiki//Users/<username>/notes
/life.org.wiki
Vimwiki: Make new directory: /Users/<username>/vimwiki//Users/<username>/notes
[Y]es/[n]o? n

or

"~/vimwiki/Tasks.wiki" 35L, 1265C written
Setup_buffer_leave g:curr_idx=0 b:curr_idx=0
"~/vimwiki/../notes/life.org.wiki" [New File]

Any help or suggestions, much obliged

Best,
tony, slowly learning vim with vimwiki :-)

Stuart Andrews

unread,
Jan 12, 2013, 9:42:49 PM1/12/13
to vim...@googlegroups.com

According to issue 386 that you quoted, a solution has been incorporated into the development version of the code.  Please download and install the latest source files.

Thanks,
- Stu

ccahua

unread,
Jan 13, 2013, 6:24:40 PM1/13/13
to vim...@googlegroups.com
Thank you, Stu!

Whew, finally got it working 

Cloning the latest default where line 444 was changed to base.vim helped silent that xdg-open error, but the file still wouldn't open in terminal vim.

Turns out I had to add a custom VimwikiLinkHandler to my .vimrc to handle vfile links as in [[vfile:<filename>]]
and since I haven't learned about tabs yet, I replaced 'tabnew' to 'split' in this line:

call vimwiki#base#edit_file('split', url, [], 0)

For folks ever running into this issue: to get files to open in plain terminal vim (no gvim):

1. Goto :h vimwiki-syntax-schemes then to the VimwikiLinkHandler section
2. Yank off that custom VimwikiLinkHandler function for vlocal and vfile in the excellent documentation!
3. Paste that function into your .vimrc
4. If you keep the function as is, vlocal and vfile links will open in a new tab, else edit that base edit file line as above
5. Now you can vim any text based file and it even works with directories, e.g. [[vfile:<directory path>]] opening with netrw, neato!

Thanks again,
tony
Reply all
Reply to author
Forward
0 new messages