Ok here is what I want to accomplish:
In INSERT mode I would like emmet to autocomplete with the TAB key
Here is what I have tried
let g:user_emmet_expandabbr_key = '<tab>' (Only works in NORMAL mode)
Though the above code is useful, I need it to work in INSERT mode
I am transferring over from Sublime Text to VIM and I miss having the Emmet functionality so easily accessible. Any ideas as to how I can achieve this?
Thanks in advance.
Solved my problem by including the following lines in my .vimrc file.
let g:user_emmet_expandabbr_key='<Tab>'
imap <expr> <tab> emmet#expandAbbrIntelligent("\<tab>")
Now I can use the TAB key to both indent and activate Emmet snippets in INSERT mode :D
I'm guessing that the reason for your setting not working in INSERT mode is because <tab> is mapped to something elsewhere (most likely with some auto-completion plugins). You can try to find what's mapped by :verbose imap <tab> when editing HTML files and disable that, but I think the simpler solution is to override the mapping yourself, like this:
augroup EmmetSettings
autocmd! FileType html imap <tab> <plug>(emmet-expand-abbr)
augroup END
To know what is done above, see :h autocmd (and :h augroup). Basically it's telling vim to execute the specified command when editing html files. To know about other mappings you can use, see the doc.
I would like to set some shortcut for set relativenumber and than I would like to set number as far I will put any key that is not number or hjkl and pass it key to active buffer. It would be really usefull for me. Is it possible?
Yes, it is possible.
Vim help give several examples on how you can accomplish this task. You should read :help 05.3, :help 40.1 and vim faq-mapping-keys.
In order to use F4 to toggle the 'relativenumber' you can use the following:
noremap <silent> <F4> :set relativenumber!<cr>
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 am a new user in Vim. How change these keys in Zen Coding,
ctr+y+,
To
ctr+e
And also change in omni,
ctr+x ctr+o
To
ctr+j
How can I do that?
I suggest you to type:
:help map.txt
inside vim, you'll find all the explanation to understand how to do it.
You can't use the same shortcut for 'zencoding' plugin and for an omnicomplete function; anyway you could add to your .vimrc:
imap <C-j> <C-y>
But I suggest not to use 'C-j' as 'j' is always related to movement in vim; use 'leader' (:help leader) which is targeted to user shortcuts, instead.
You may follow the answer provided by #eolo999, but I suggest you to read zencoding documentation and add the following to the vimrc:
" Note the `nore'. You must use it where possible "
" in order not to get remapping problems when your vimrc grows up "
inoremap <C-j> <C-x><C-o>
" from :h zencoding-customize-keymappings "
let g:user_zen_expandabbr_key='<C-e>'
This question already has answers here:
Vim clear last search highlighting
(32 answers)
Closed 3 years ago.
I search for "nurple" in a file. I found it, great. But now, every occurrence of "nurple" is rendered in sick black on yellow. Forever.
Forever, that is, until I search for something I know won't be found, such as "asdhfalsdflajdflakjdf" simply so it clears the previous search highlighting.
Can't I just hit a magic key to kill the highlights when I'm done searching?
:noh (short for nohighlight) will temporarily clear the search highlight. The next search will still be highlighted.
Just put this in your .vimrc
" <Ctrl-l> redraws the screen and removes any search highlighting.
nnoremap <silent> <C-l> :nohl<CR><C-l>
/lkjasdf has always been faster than :noh for me.
" Make double-<Esc> clear search highlights
nnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc>
Then I prefer this:
map <F12> :set hls!<CR>
imap <F12> <ESC>:set hls!<CR>a
vmap <F12> <ESC>:set hls!<CR>gv
And why? Because it toggles the switch: if highlight is on, then pressing F12 turns it off. And vica versa. HTH.
Append the following line to the end of your .vimrc to prevent highlighting altogether:
set nohlsearch
*:noh* *:nohlsearch*
:noh[lsearch] Stop the highlighting for the 'hlsearch' option. It
is automatically turned back on when using a search
command, or setting the 'hlsearch' option.
This command doesn't work in an autocommand, because
the highlighting state is saved and restored when
executing autocommands |autocmd-searchpat|.
Same thing for when invoking a user function.
I found it just under :help #, which I keep hitting all the time, and which highlights all the words on the current page like the current one.
I think the best answer is to have a leader shortcut:
<leader>c :nohl<CR>
Now whenever you have your document all junked up with highlighted terms, you just hit , + C (I have my leader mapped to a comma). It works perfectly.
I search so often that I've found it useful to map the underscore key to remove the search highlight:
nnoremap <silent> _ :nohl<CR>
I think this answer in "Vim clear last search highlighting" is better:
:let #/ = ""
There is hlsearch and nohlsearch. :help hlsearch will provide more information.
If you want to bind F12 to toggle it on/off you can use this:
map <F12> :nohlsearch<CR>
imap <F12> <ESC>:nohlsearch<CR>i
vmap <F12> <ESC>:nohlsearch<CR>gv
I have this in my .vimrc:
nnoremap ; :set invhlsearch<CR>
This way, ; will toggle search highlighting. Normally, the ; key repeats the latest t/T/f/F command, but I never really used that functionality. I find this setting much more useful, because I can change search highlighting on and off very quickly and can easily get a sense of where my search results are, at a glance.
Also, if you want to have a toogle and be sure that the highlight will be reactivate for the next time you search something, you can use this
nmap <F12> :set hls!<CR>
nnoremap / :set hls<CR>/
I add the following mapping to my ~/.vimrc
map e/ /sdfdskfxxxxy
And in ESC mode, I press e/