Skip to content

⚙ Vim Plugin - Helps you switch between windows, tabs and files

License

Notifications You must be signed in to change notification settings

flatcap/vim-tabitha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tabitha.vim

Introduction

Tabitha helps you switch between windows, tabs and files.

The plugin creates two mappings: <Tab> to move forwards and <S-Tab> to move backwards. Pressing <Tab> in normal mode will move the focus to the next window. If there are no more windows, the next tab will be selected.

If there is only one window and one tab, then Tabitha will switch to the next file in the arglist.

By pressing <S-Tab> the focus will be moved to the previous window, tab or file.

The default mappings support a count. Therefore pressing 3<Tab> will move the focus forward three windows, tabs or files.

Configuration

The behaviour of Tabitha is controlled by five global variables:

let g:tabitha_navigate_windows = 1
let g:tabitha_navigate_tabs    = 1
let g:tabitha_navigate_files   = 1
let g:tabitha_wrap_around      = 1
let g:tabitha_select_window    = 1

The default behaviour is to switch to the next window. If there are no more windows, then the first window of the next tab will be selected. When the final window of the final tab is reached, the focus will wrap around to the first window of the first tab.

By choosing which variables to set, you can choose to cycle through:

  • Just Windows
  • Windows and Tabs
  • Just Tabs
  • Just Files

When switching between tabs, the select_window option controls whether the focus should be set to the first window in that tab.

Mappings

By default, Tabitha will create two key mappings and eight plugin mappings:

<Tab>   Move forwards through windows/tabs
<S-Tab> Move backwards through windows/tabs

<Plug>TabithaNextWindow
<Plug>TabithaPreviousWindow

<Plug>TabithaNextTab
<Plug>TabithaPreviousTab

<Plug>TabithaNextFile
<Plug>TabithaPreviousFile

<Plug>TabithaSwitchForwards
<Plug>TabithaSwitchBackwards

These can be disabled by setting:

let g:tabitha_create_mappings = 0

You can create your own Tabitha mappings, e.g.

" Move focus forwards
nmap <silent> <F3> <Plug>TabithaSwitchForwards
nmap <silent> <F3> :<C-u>call tabitha#Switch (1)<CR>

" Move focus backwards
nmap <silent> <F4> <Plug>TabithaSwitchBackwards
nmap <silent> <F4> :<C-u>call tabitha#Switch (0)<CR>

" Select next tab
nmap <silent> <Leader>t <Plug>TabithaNextTab
nmap <silent> <Leader>t :<C-u>call tabitha#NextTab (1, 0, 0)<CR>

" Select previous file
nmap <silent> <Leader>F <Plug>TabithaPreviousFile
nmap <silent> <Leader>F :<C-u>call tabitha#NextFile (0, 0)<CR>

API

Tabitha introduces four functions to vim. Their behaviour is configured by five variables, described in 'Configuration', above.

function! tabitha#NextWindow (...)
function! tabitha#NextTab (...)
function! tabitha#NextFile (...)
function! tabitha#Switch (...)

NextWindow

NextWindow moves the cursor to the next/previous window. It takes two optional parameters. It returns 1 if the focus was changed, 0 otherwise.

tabitha#NextWindow (forwards, wrap)
Parameter Default Description
forwards 1 (true) direction of change
wrap 1 (true) wrap around at end of window list

e.g.

call tabitha#NextWindow ()
call tabitha#NextWindow (1, 1)

NextTab

NextTab moves the cursor to the next/previous tab. It takes three optional parameters. It returns 1 if the focus was changed, 0 otherwise.

tabitha#NextTab (forwards, wrap, select_window)
Parameter Default Description
forwards 1 (true) direction of change
wrap 1 (true) wrap around at end of tab list
select_window 1 (true) when switching tabs, pick the first/last window

e.g.

call tabitha#NextTab ()
call tabitha#NextTab (1, 0, 0)

NextFile

NextFile moves the cursor to the next/previous file. It takes two optional parameters. It returns 1 if the focus was changed, 0 otherwise.

tabitha#NextFile (forwards, wrap)
Parameter Default Description
forwards 1 (true) direction of change
wrap 1 (true) wrap around at end of file list

e.g.

call tabitha#NextFile ()
call tabitha#NextFile (1, 1)

Switch

Switch moves the cursor to the next/previous window/tab/file (dependent on configuration). It takes one optional parameter. It returns the number of times the focus moved, 0 if nothing changed.

tabitha#Switch (forwards)
Parameter Default Description
forwards 1 (true) direction of change

e.g.

call tabitha#Switch ()
call tabitha#Switch (1)

Naming

The plugin is whimsically named after the default key mapping. The name 'Tabitha' is derived from an Aramaic word meaning gazelle.

License

Copyright © Richard Russon (flatcap). Distributed under the GPLv3 http://fsf.org/

See also