aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2020-06-05 00:46:50 +0200
committerTeddy Wing2020-06-05 00:46:50 +0200
commitfaff69f8ec90996d7ec4115abf1fca553f33414f (patch)
tree7bda0a602360f9978d1e7285404355836172d795
downloadvim-tbuffer-faff69f8ec90996d7ec4115abf1fca553f33414f.tar.bz2
TBuffer command to open the tab page containing the specified buffer
Like `:buffer`, except it switches to the tab page containing the specified buffer instead of opening in the current window.
-rw-r--r--tbuffer.vim16
1 files changed, 16 insertions, 0 deletions
diff --git a/tbuffer.vim b/tbuffer.vim
new file mode 100644
index 0000000..b19b61e
--- /dev/null
+++ b/tbuffer.vim
@@ -0,0 +1,16 @@
+function! TBuffer(file)
+ " save swb
+ " swb=usetab
+ " b $1
+ " restore swb
+
+ let switchbuf_save = &switchbuf
+
+ let &switchbuf = 'usetab'
+
+ execute 'sbuffer ' . a:file
+
+ let &switchbuf = switchbuf_save
+endfunction
+
+command! -nargs=1 -complete=buffer TBuffer call TBuffer(<q-args>)