Skip to content

Enhancement: Reuse Vim Tabs with drop #238

@davidlmontgomery

Description

@davidlmontgomery

I use vim and gvim opening many files in new tabs. I found that when following links forward and back vimwiki would frequently create a new tab for a file that was already open, so that I would end up with the same file open many times. My preference is to reuse the existing tab.

Below are two patch files for how I hacked my local vimwiki to reuse tabs instead of creating new ones.


--- markdown_base.vim   2016-07-02 14:13:32.750195233 -0700
+++ markdown_base.vim   2016-07-02 14:11:47.274198885 -0700
@@ -86,9 +86,9 @@
     elseif a:split ==# "vsplit"
       let cmd = ":vsplit "
     elseif a:split ==# "tabnew"
-      let cmd = ":tabnew "
+      let cmd = ":tab drop "
     else
-      let cmd = ":e "
+      let cmd = ":drop "
     endif

     " try WikiLink


--- base.vim    2016-07-02 14:13:21.342195628 -0700
+++ base.vim    2016-07-02 14:08:44.654205208 -0700
@@ -1270,7 +1270,7 @@
   if exists("b:vimwiki_prev_link")
     " go back to saved wiki link
     let prev_word = b:vimwiki_prev_link
-    execute ":e ".substitute(prev_word[0], '\s', '\\\0', 'g')
+    execute ":drop ".substitute(prev_word[0], '\s', '\\\0', 'g')
     call setpos('.', prev_word[1])
   else
     " maybe we came here by jumping to a tag -> pop from the tag stack

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions