Reply to message «supertab en nextfield script», sent 16:37:05 05 November 2010, Friday by rameo:
> Nextfield script can be used to let VIM work as a tabulator (as on the > old typewriter machine). This is very useful when writing a table. > Nextfield uses the <tab> and <s-tab> key. > > Supertab uses the <tab> and <s-tab> key also. > > I would like to disable Supertab on the fly when I want to use > Nextfield and enable Supertab again when I finished using Nextfield. > > Is there a way to resolve this problem? Yes, it is possible. Here are the steps: 1. Install vim-addon-manager: http://www.vim.org/scripts/script.php?script_id=2905 2. Put the following into .vimrc: let g:vim_script_manager={"plugin_root_dir": expand('~/.vam')} try call scriptmanager#Activate("SuperTab_continued.") catch endtry " Assuming that <Tab> is remapped in normal mode: let s:map_tab_supertab = maparg("<Tab>", "i", 0, 1) let s:map_s_tab_supertab = maparg("<S-Tab>", "i", 0, 1) function s:GetMapCmd(mode, noremap) let cmd=((a:noremap)?("nore"):(""))."map" if a:mode!=#'!' && a:mode!=#' ' return a:mode.cmd elseif a:mode==#'!' return cmd.a:mode endif return cmd endfunction function s:RestoreMap(exmap) if empty(a:exmap) return endif let exmap=a:exmap execute s:GetMapCmd(exmap.mode, exmap.noremap)." <special> ". \((exmap.buffer)? ("<buffer> "):("")). \((exmap.silent)? ("<silent> "):("")). \((exmap.expr)? ("<expr> "): ("")). \exmap.lhs." ". \substitute(exmap.rhs, '<SID>', '<SNR>'.exmap.sid.'_', \ 'g') endfunction inoremap <S-Tab> <C-O>:call NextField(' \{2,}',2,' ',0)<CR> " I do not find mapping to tab in that tip. Put it here let s:map_tab_nextfield = maparg("<Tab>", "i", 0, 1) let s:map_s_tab_nextfield = maparg("<S-Tab>", "i", 0, 1) let s:next_map="nextfield" call s:RestoreMap(s:map_tab_supertab) call s:RestoreMap(s:map_s_tab_supertab) function s:AlterMap() call s:RestoreMap(s:map_tab_{s:next_map}) call s:RestoreMap(s:map_s_tab_{s:next_map}) if s:next_map is "nextfield" let s:next_map="supertab" else let s:next_map="nextfield" endif endfunction command -nargs=0 AlterTab call s:AlterMap() 3. Start new vim, answer yes on all queries. 4. You can now alter <tab> and <S-Tab> behavior with :AlterTab.
signature.asc
Description: This is a digitally signed message part.
