restore tab key binding to default action - vim

One of vim plugin added this mapping, which starts auto completion when I press tab.
s <Tab> * <Esc>i<Right><C-R>=TriggerSnippet()<CR>
How do I restore the tab mapping to insert spaces instead of autocomplete. I tried various noremap but it did not take effect or simply did nothing. unmap do not help either.
Vim version 7.2
CentOS 6.4

Use :unmap <Tab>, considering the mode(s). You've shown the :smap (presumably of the snipMate plugin), but the behavior you've described is the :imap.
Now, that unmap needs to be done after the plugin has defined the mapping, so you can't do that in your ~/.vimrc. Usually you put the commands into ~/.vim/after/plugin/<pluginname>.vim, but snipMate already uses such a file to define the mapping! Therefore, choose a name in the after directory that alphabetically comes after snipMate, e.g. ~/.vim/after/plugin/zzzSnipMate.vim.
As you probably want to define different mapping keys for it (otherwise you could just uninstall the plugin, right?), you can do that there, too.

Related

Mapping TO ctrl+[something] doesn't work in gvim

I am using GVim 7.4 and I would like to do some really simple mapping to use CtrlP fuzzy matching of tags when a key combination is used.
I tried 2 approaches and they all seem to fail when vim calls Control + [x] combination. While I do understand that there are restrictions when it comes to mapping Ctrl+[x] codes, I haven't found any information on why ctrl mapping wouldn't work.
noremap \t :CtrlPTag<CR><C-\>w
This one enters CtrlP tag mode but then it doesn't enter word from under the cursor.
noremap \t <C-p><C-\>w
Here we don't even get to CtrlP window (I even omit going into tag mode here for simplicity).
As far as I understand (I'm no CtrlP user), the plugin is triggered via some command / key combination, and then presents interactive selection and filtering. It even has different "source" modes.
Now, this is a pretty heavy integration into Vim, probably using scratch buffers and its own input loop. That's why you cannot simply append keys to the mapping and get them interpreted by the plugin "as typed".
Typically, these plugins offer mode selection and so on via (optional) command arguments. Check the plugin's help, and if you cannot get the plugin into the state you need, best contact the plugin's author and ask for such enhancement.

Vim: How to compose search with another command?

I just installed sweet vim plugin that provides context colouring for javascript. I've fiddled with the colours so that they are just right, and am pretty pleased. However, there are times when I don't want the context colouring:
in insert mode, since the colouring doesn't work well while I'm editing
when I'm search, since the colouring seems to override the search hl
I resolved the first problem with:
autocmd InsertEnter *.js :JSContextColorToggle
autocmd InsertLeave *.js :JSContextColorToggle
However, the second problem is trickier. At first I thought I could just map /, my search key, so that it would first toggle the context colouring and then perform the search. I haven't been able to figure out how to write that mapping, though. How would I store "the original meaning of /" for use in my map?
Thanks,
p.s. check out this sweet context colouring (with solarized).
Hi I'm the author of the plugin. I fixed the conflict with hlsearch so it should just work now (try pulling latest version from git, I've not updated vim.org yet..)
As for the insert mode behaviour, there is a difference in behaviour between vim 7.3 and 7.4. 7.4 has the 'TextChanged' and 'TextChangedI' events, which fire when text is changed in normal , and insert mode respectively. This triggers the highlighting to update. However the TextChangedI event only fires on leaving insert mode. So if this is the behaviour you want, you can get it by upgrading to 7.4. In 7.3 I had to hook into the cursormoved event, which checks the 'b:changedtick' variable, which vim updates whenever changes occur... I'm not sure if this can occur during insert mode, but I think it might, which would explain odd behaviour if you're using 7.3.
I'm still trying to figure out what the best behaviour should be in insert mode...its tricky because the code syntax my be invalid during editing, and when the code cannot be parsed the plugin cannot work (and you will see regular syntax highlighting appear.. this may be a good thing as one value of syntax highlighting is visual syntax checking!). Another option would be to assume it is the same level as at the point where editing started, and offset the following text by however many characters are added/deleted during editing. Yet another option would be to have syntax highlighting in the area being edited (current line?) .
/ will enter command-mode.
if you only want to toggle highlighting with /, I think you need map <expr>.
something like
nnoremap <expr> / YourFunction()
in YourFunction(), you first do turn off the syntax hi, then return a /.
However you have to think about when to restore the hi. you can create another command mode mapping, map <cr> to first turn on the js hi, then return <cr>.
or just create an autocmd, when entering Normal mode, turn on the highlighting.
I didn't test above idea, hope it helps.

Why can I map <M-w> but not <M-r> in gvim?

I successfully defined a mapping to be invoked with ALT+w like so :map <M-w> ....
Yet, if I try to define a new mapping to be invoked with ALT+r like so :map <M-r> ... it doesn't work. Instead, the character ò (if the mapping is invoked in insert mode) is inserted. This is the same character that is inserted without mappings at all (and also with gvim started with gvim -u NONE).
I don't understand why one mapping works and the other doesn't.
Edit to answer some quiestions
I am working on a german Windows 7. The current keyboard layout is English (USA)
When I press Alt+w in insert mode without mapping, I get a ÷.
Both mappings works on my machine.
Maybe there is some problem with your mapping command, or it is still being changed by some setting you are using. Despite of using u -NONE you could try some other switches, as -U and -i; more info on this can be found on vim faq 36.12. You could also try with noremap instead of map.
"20.4. I am not able to create a mapping for the key. What is wrong?" has some additional suggestions.

How to check if SuperTab and jedi-vim is activated?

As the title states, how do I check if a plugin is loaded?
When I hit tab (for SuperTab) all I get is the ordinary character "tab" inserted in my file and when I hit ctrl-space I just get thrown out of insert-mode (same behavior as hitting ESC)
The :scriptnames command lists all scripts that have been sourced; check for the plugin name in its output. If it's missing, it is either due to a wrong installation or because 'runtimepath' is incorrect.
Alternatively, if you know the mapping a plugin should define
:verbose imap <Tab>
will show the mapping and from which script is was set.
Programmatically, it is best to check for the canonical include guard if exists('g:loaded_pluginname') or for a defined command via if exists(':PluginCommand').

mapping already exists for ^I in vim

I have added the following lines to the vimrc file so that i could use s-tab for indenting
map <esc>[Z <s-tab>
ounmap <esc>[Z
After i have added this , i get the following error. I use SnippetsEmu plugin
Error detected while processing function <SNR>15_SnipMapKeys:
line 10:
E227: mapping already exists for ^I
How do i solve this conflict.Why does this happen
A helpful way you can detect whether your version of vim is capable of differentiating between Tab and Shift-Tab is to:
Go into insert mode, press Ctrl-v* then Shift-Tab. I get <S-Tab> when I do that (gvim 7.2 on Windows XP).
If you don't get that then I don't think you can map Shift-Tab separately from Tab with your current setup.
*Ctrl-v will take the next key combination you press and output the key combination that vim actually sees.
EDIT: If you're sourced mswin.vim then you'll want to use Ctrl-q instead.

Resources