i just tried to install snipmate. supertab is already working.
it doesnt work. when i press tab even after a snippet keyword the completion is triggered.
i tried to remap the key (to c-m) but even then completion is triggered instaed of snipmate. (before the remap c-m didnt do a thing).
i did this mapping in vimrc. the doc tells me to do it in after/plugin/snipmate.vim but this script isnt loaded (according to :scriptnames).
any idea?
snipmate plugin hasn't been updated for a long long time. thats why i started a friendly fork and i'm merging and coordinating further development of this (at least for me) essential plugin.
more here: https://github.com/garbas/vim-snipmate/blob/master/README.md
I had a very similar problem running an old version of snipmate from vim.org
The guy who writes it doesn't always update the vim.org page, but he does work on it fairly regularly on github.
Grab the latest copy from the download link here and see if that helps you.
What did you remap to <C-m>? <Tab> or your plugins function calls? Did you try SnipMate without SuperTab?
Both plugins have their main functions hardwired to <Tab> which makes their use a bit unpredictable. I've tried it but I didn't like it.
Instead, maybe you can keep SnipMate (if it works on its own) and remap omnicompletion shortcuts to something easier. I have these in my .vimrc:
" change the mapleader from \ to ,
let mapleader=","
" omnicompletion : words
inoremap <leader>, <C-x><C-o>
" omnicompletion : filenames
inoremap <leader>: <C-x><C-f>
" omnicompletion : lines
inoremap <leader>= <C-x><C-l>
Also autocomplpop.vim works very well.
Use SuperTab 2.0 version.
Do not use the latest version 2.1, it doesn't work with each other.
I managed to remap SnippMate's TAB key to a different key, in my case c-j, and it worked OK:
ino <silent> <c-j><c-r>=TriggerSnippet()<cr>
snor <silent> <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
I did the change in after/plugin/snipmate.vim. In my case, :scriptnames listed the file as loaded.
add it to .vimrc, when you use Tab, then show the list of snippets.
au BufRead,BufNewFile *.py set expandtab
au BufRead,BufNewFile *.sh set expandtab
au BufRead,BufNewFile *.go set expandtab
Related
A plugin adds to my insert mappings a mapping for <leader>is. I have some ideas which one it can be. But it does not matter I don't want to change anything in foreign plugins. So I want to disable this mapping. I tried this:
imap <leader>is <nop>
I did not help.
What is your suggestions?
BTW, I want to ask how disable in vimrc all insert mapping of plugins?
To remove an insert mode mapping, use the :iunmap command:
:iunmap <Leader>is
I don't know whether it is possible to do "bulk unmapping", but at least you can list all active insert mode mappings with
:imap
or, even better, with
:verbose imap
which will also tell you where the mapping has been defined in the first place.
Edit: To clarify, the unmapping needs to be done after the plugin has been loaded. To do so, create a file with the following contents in ~/.vim/after/plugin/ (see #ZyX's answer):
" myafter.vim: will be executed after plugins have been loaded
iunmap <Leader>is
Your command if inserted in the vimrc is executed before plugin defines the intrusive mapping and this is why it has no effect. To make it have effect you should make it run after that plugin which is normally achieved either by putting it into ~/.vim/after/plugin/disable_mappings.vim (any name instead of disable_mappings works). Second is using VimEnter event:
augroup DisableMappings
autocmd! VimEnter * :inoremap <leader>ic <Nop>
augroup END
. To disable all mappings see :h 'paste' and :h 'pastetoggle', also :h :imapclear (though the latter will remove mappings instead of temporary disabling them).
Of course, you may also use iunmap just where I suggested to use inoremap … <Nop>. How did I came to forget this command?
I'm on this computer (ubuntu) where TAB is mapped (I can't find where) to autocomplete. I searched and seems like this is done by supertab, although I couldn't find how to disable it, neither did I find its files.
In my ~/.vimrc and /usr/share/vim/vimrc files, there is no mapping of the tab key. The later file includes debian.vim (and tries with /etc/vim/vimrc.local, but that doesn't exist) but that also doesn't have any mappings of tab, or any reference to supertab.
The output of :map! is this:
i <S-Tab> * <C-R>=BackwardsSnippet()<CR>
i <Plug>SuperTabBackward & <C-R>=<SNR>13_SuperTab('p')<CR>
i <Plug>SuperTabForward & <C-R>=<SNR>13_SuperTab('n')<CR>
i <C-Tab> * <Tab>
i <Tab> * <C-R>=TriggerSnippet()<CR>
i <CR> * <C-R>=<SNR>13_SelectCompletion(1)<CR>
i <C-N> <Plug>SuperTabForward
i <C-P> <Plug>SuperTabBackward
i <C-R><Tab> * <C-R>=ShowAvailableSnips()<CR>
i <C-X> <C-R>=<SNR>13_ManualCompletionEnter()<CR>
Which indicates that supertab is indeed mapping these keys.
I tried putting nomap! <TAB> in my ~/.vimrc, but it doesn't work as it seems like supertab is being loaded after ~/.vimrc is read.
My question is, how can I disable supertab, or alternatively make sure ViM doesn't let anyone map TAB to anything else?
Supertab is a plugin. As such it should be installed somewhere in ~/.vim/. There are many ways to install plugins (default, pathogen, vundle, etc.). Look into ~/.vim/bundle (if you use Pathogen) or in ~/.vim/plugin.
If it's not there it may have been installed in /usr/share/vim/vim7x/ which is very crowded and should not be touched in any way: good luck.
Anyway, you can do :verbose map! to see where the mappings are set (and thus, where the plugin is installed if you want to remove it) or you could simply configure Supertab to not use <tab>. See :help supertab.
In case you don't want to completely get rid of supertab you can remap the default keybindings using something like (in your ~/.vimrc):
let g:SuperTabMappingForward = '<c-space>'
let g:SuperTabMappingBackward = '<s-c-space>'
If you only want to insert literal tab characters, supertab makes it easy by mapping literal tabs to ctrl+tab by default (which unfortunately doesn't work in terminal). It can be customized by using something like:
g:SuperTabMappingTabLiteral='<C-`>'
Lastly, you can always escape a mapping by prepending it with ctrl-v in insert mode.
see :h supertab-forwardbackward for more information. (might not work if you haven't built supertab docs)
What do people recommend for easier manipulation of buffers in vim?
Using ls and b1, bn and bp commands is good but maybe there is a better way.
Is lusty explorer the best option?
I am using vim 7.3.
You should test all of them and see which one is the best according to your tastes and requirements.
I've used LustyExplorer for a while and loved it until I tried CtrlP which I find faster and more intuitive. I have :CtrlPBuffer mapped to ,b and see no reason to complain: it's both elegant, fast and intuitive.
You don't have to rely on plugins, though: :b <tab> allows you to tab through a list of all available buffers. You can do :b pattern<Tab> to get a smaller list.
Unite.vim is a new plugin and is what I switched to from CtrlP.
This is a good starting point if you want to explore what it can do.
I use minibufexpl.vim. I guess its main advantage is that it takes up very little space.
FuzzyFinder is another excellent add-on for buffer/file navigation:
http://www.vim.org/scripts/script.php?script_id=1984
Whichever plugin you choose for this, it's worth investing some time to find out all the ways it can help you.
If you are fine with having vim compiled with ruby support and have dev toolchain installed on the system (make, gcc, maybe something else — Gentoo users like me already have all of this) then Command-T is a good choice. To use it for switching buffers you should map something to :CommandTBuffer, I have
nnoremap ,b :CommandTBuffer<CR>
I used many plugins before, including minibufexpl and Bufexplorer, but there was something in all of them that used to annoy me.
Now I use young plugin Buffet, and I would recommend it because it seems to be really the best one for me: it is really fast and easy to use.
Personally i would like to switch my buffers by Ctrl+Tab and Shift+Ctrl+Tab, and buffers should be ordered in most-recently-used order.
Here is my buffet's config to achieve <C-Tab> and <S-C-Tab> switching:
noremap <silent> <C-Tab> :Bufferlistsw<CR>
noremap <silent> <C-S-Tab> :Bufferlistsw<CR>kk
if !has('gui')
map <S-q> :Bufferlistsw<CR>
endif
augroup BuffetAdd
if !exists("g:BuffetAdded")
let g:BuffetAdded = 1
au BufWinEnter buflisttempbuffer* map <buffer> <Tab> <CR>
au BufWinEnter buflisttempbuffer* map <buffer> <C-Tab> j
au BufWinEnter buflisttempbuffer* map <buffer> <C-S-Tab> k
" in console Vim we can't use <C-Tab> mappings (almost always),
" so this is temporary solution: <S-q>
if !has('gui')
au BufWinEnter buflisttempbuffer* map <buffer> <S-q> j
au BufWinEnter buflisttempbuffer* map <buffer> q <CR>
endif
" workaround Surround plugin issue in Buffet's window:
" disable "ds" mapping in the Buffet window (to make "d" work fast)
au BufEnter buflisttempbuffer* nunmap ds
au BufLeave buflisttempbuffer* nmap ds <Plug>Dsurround
endif
augroup END
Just one issue: Vim does not allow you to map release of some key, so, you need to press Tab again to really switch to buffer.
Anyway, if you don't need <C-Tab> switching, Buffet plugin works nice without it.
Update June 2019
BufExplorer is my unequivocal first-choice for buffer management.
" Buffer explorer
" ,be to open, q to close, d to delete buffer
Plug 'jlanzarotta/bufexplorer'
Highly rate the above plugin. It's simple and effective. Further details in the readme.
If you're looking for some "extras" in addition to the above (optional), I do also use:
" Close buffers but keep splits
Plug 'moll/vim-bbye'
and:
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
" this setting for quick search across buffers
nmap <silent> <leader>b :Buffers<cr>
Vim is installed at /usr/share/vim.
All snipMate's folders were added to this category in existing folders (after, autoload, plugin, snippets, etc.) accordingly.
From the documentation file:
For instance, to change the trigger
key to CTRL-J, just change this:
ino <tab> <c-r>=TriggerSnippet()<cr>
snor <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
to this:
ino <c-j> <c-r>=TriggerSnippet()<cr>
snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
I tried this as well - the same result.
When I try to trigger snippet match it only adds a tab (4 spaces, accordingly to my .vimrc).
P.S. filetype plugin indent on.
Updated:
cat /etc/issue
Ubuntu 9.10
:inoremap
i <C-B> * <C-R>=TriggerSnippet()<CR>
:snoremap
s <C-B> * <Esc>i<Right><C-R>=TriggerSnippet()<CR>
How can I fix this?
I solved this problem by removing the 'set paste' entry on .vimrc
I had a problem with snipMate, it wasn't working, so I came across with Issue 66 in their Issue Tracker:
source ~/.vim/after/plugin/snipMate.vim
In my case, I experienced the same thing. SnipMate autocomplete does not work. One of the reasons is the is used by other plugin. Typing :verbose imap <Tab> will show you which plugin that utilizes the key and cause the conflict. You can either comment out the plugin in .vimrc or you can change it to use another key.
I am trying to use snipMate and pydiction in vim together - however, both use the <tab> key to perform their genius-auto-completion-snippet-rendering-goodness-that-I-so-desire.
When pydiction is installed, snipMate stops working. I assume its because they can't both own the <tab> key. How can I get them to work together?
I wouldn't mind mapping one of them to a different key, but I am not really sure how to do this ... (maybe pydiction to the <ctrl-n> key so it mimics vim's autocomplete?).
Here is the relevant .vimrc:
filetype indent plugin on
autocmd FileType python set ft=python.django
autocmd FileType html set ft=html.django_template
let g:pydiction_location = '~/.vim/ftplugin/pydiction-1.2/complete-dict'
Well, this is from the Snipmate help file :)
*snipMate-remap*
snipMate does not come with a setting to customize the trigger key, but you
can remap it easily in the two lines it's defined in the 'after' directory
under 'plugin/snipMate.vim'. For instance, to change the trigger key
to CTRL-J, just change this: >
ino <tab> <c-r>=TriggerSnippet()<cr>
snor <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
to this: >
ino <c-j> <c-r>=TriggerSnippet()<cr>
snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
Alternatively, you can edit ~/.vim/after/ftplugin/python_pydiction.vim
and change Tab to something else:
" Make the Tab key do python code completion:
inoremap <silent> <buffer> <Tab>
\<C-R>=<SID>SetVals()<CR>
\<C-R>=<SID>TabComplete('down')<CR>
\<C-R>=<SID>RestoreVals()<CR>
" Make Shift+Tab do python code completion in the reverse direction:
inoremap <silent> <buffer> <S-Tab>
\<C-R>=<SID>SetVals()<CR>
\<C-R>=<SID>TabComplete('up')<CR>
\<C-R>=<SID>RestoreVals()<CR>
I believe the way to change the trigger key may have changed since the answer by the_karel was given in 2009 but it is found in the same directory, namely 'after/plugin/snipMate.vim'. I found it in the help file too:
*snipMate-trigger*
snipMate comes with a setting to configure the key that is used to trigger
snipMate. To configure the key set g:snips_trigger_key to something other than
<tab>,e.g. <c-space> use:
let g:snips_trigger_key='<c-space>'