Git Product home page Git Product logo

bettertabs.vim's Introduction

betterTabs.vim

BetterTabs allows you to keep the a separation between tabs in Vim: Each buffer stays on the tab it was open in. This way you can keep one project per tab and don't find buffers switching from a tab to another breaking your workflow.

Important note This plugin is still in development, it might then contains different bugs or unwanted behavior. If you find one please create a new issue.

The idea

I created this plugin because I had to work on different projects with gVim on a Windows OS. To do that in a terminal version of Vim I usually use different instances of Vim open on several tmux terminal.

Unfortunately switching between several instances of gVim on a graphical OS feels pretty inconvenient to me. So I created one tab per project, but I was bothered by the fact that a buffer open in a tab could be accessed in any other tab.

So I created this plugin it simply allows you to keep every buffer in the tab it was open in.

Installation

BetterTabs should be compatible with most of the plugin managers. I'd recommand using Vim-Plug: simply add the following line to your .vimrc:

Plug 'statox/betterTabs.vim'

Save your .vimrc, execute PlugInstall and voilà!

The plugin is entirely in vimscript, it doesn't need any dependencies.

How to use it

Adding a buffer to a tab

This plugin uses autocommands when a new buffer is created so the user doesn't have to worry about how they're handled. Simply open tabs as you usually do and use your prefered way to open a buffer.

Once a buffer is open in a tab it can't be accessed from another tab. To switch between tabs the user can use tabnext and tabprevious as usual.

Switching between buffers

To switch between the buffers of a tab use the commands :NextBuf and :PrevBuf.

The plugin also defines the following mappings:

nnoremap <Leader>h :PrevBuf<CR>
nnoremap <Leader>l :NextBuf<CR>

You can then use <Leader>h and <Leader>l to switch between the buffers.

Closing a buffer

To keep the behavior of this plugin consistent, users shouldn't use bdelete but the command :CloseBuf.

The following mapping is also defined:

nnoremap <Leader>bc :CloseBuf<CR>

So the user can use <Leader>bc to close a buffer.

Closing a tab

To keep the behavior of this plugin consistent, users shouldn't use tabclose but the command :CloseTab.

Listing the buffers

The command :ListBuf allows you to see the different tabs open and the buffers contained in the tabs.

You can also use F2 to print the list thanks to the following mapping:

nnoremap <F2> :ListBuf<CR>

Disabling mappings

It is possible to disable the default mappings to override them, simply add the following line to your .vimrc:

let g:betterTabsVim_map_keys = 0

bettertabs.vim's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.