Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers.
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
created 2006 · complexity basic · author hari_vim · version 7.0
Occasionally users will improperly use the commands
:qa! instead of the proper
:tabclose to close a tab in a session, quitting the entire session instead. A few methods can be used to remap the
:tabclose command to a more memoriable command as outlined below.
Remap :tabclose to QAEdit
This method requires the plugin cmdalias.vim plugin. This plugin will allow you to keep your abbreviations in the context of a : command. Once this plugin is loaded add the following to your vimrc to create a user command for
command! -bang QA :call TabQAll('<bang>') function! TabQAll(bang) try if tabpagenr('$') > 1 exec 'tabclose'.a:bang else exec 'qa'.a:bang endif catch echohl ErrorMsg | echo v:exception | echohl NONE endtry endfunction
Finally create an abbreviation for
:qa to mean
:QA which will allow you to not have to remember
:QA making it easier to use the command you are already familiar with to "close" your tab. To accomplish this add the following to your vimrc:
function! InitPlugins() call CmdAlias('qa', 'QA') au! InitPlugins VimEnter endfunction aug InitPlugins au! au VimEnter * :call InitPlugins() aug END
:qa in a tab will close out the tab.
Note the use of a VimEnter autocmd instead of calling CmdAlias directly in the vimrc. This is done, because the plugin needs to be loaded before the functions defined in the plugin can be used. Since plugins are loaded after the .vimrc, VimEnter allows the plugin to load before the function is called.
Firefox Tab CloseEdit
Some users find it easier to map tab commands to the Firefox key-stroke patterns (Ctrl + T = New Tab, Ctrl + F4 = Close Tab). To do so, add the following to your vimrc:
"Vim 7 specific mappings if version >= 700 map <C-t> <Esc>:tabnew<CR> map <C-F4> <Esc>:tabclose<CR> endif
- Replace a builtin command using cabbrev tells you how to accomplish something similar to cmdalias.vim without the plugin