Mapping leader key to execute something without having to press enter - vim

I mapped leader lf to LustyFileSystemExplorer and it works properly. I press leader lf and it shows the explorer, however when I change it to any other key binding, pressing leader lf shows :LustyFileSystemExplorer and I've to press enter to use it.

Add a carriage return to your mapping:
map <Leader>lf :LustyFileSystemExplorer<CR>
And you're done!

Related

Pressing <press Alt-3> suddenly maps to Esc (and not the character "#"

Pressing suddenly seems to map to the command Esc (and not the character "#", How do I access the map.
I tried the following command:
:unmap <Alt-3>
:unmap <Alt-3> Esc
:unmap <press Alt-3>
:unmap <press Alt-3> Esc
I want be able to write the character "#" with the shortcut Alt-3
The problem was in your iTerm configuration, which was set to send ESC+3 when <Alt-3> was pressed.
You can solve the problem be going to iTerm2 menu Preferences > Profiles > Keys and setting Left Option (alt) Key there, changing from "Esc+" to "Normal".

When I search in vim and then press “esc” cursor returns to previous position

Something has seemingly happened to my vim install, and I'm not exactly sure what. I'm a long time vim user (although I don't use it as a main editor).
When I search:
/foo
I want to edit the location that it found, so I press ESC (in preparation for getting into insert mode). vim now jumps BACK to where I started from in the file. E.g. if I was on line 0 of a 3000 line file, I search for a particular string, find it at line 1700, and want to edit it - ESC takes me back to line 0.
What's going on? Did I accidentally set some strange mode? Or did I forget a hotkey combination that I should know?
This is the expected behaviour with the incsearch option on:
Note that the match will be shown, but the cursor will return to its
original position when no match is found and when pressing <Esc>. You
still need to finish the search command with <Enter> to move the
cursor to the match.
If incsearch is not on then the cursor doesn't jump to the first match at all, it doesn't move until you press <Enter>.
you said
so I press ESC (in preparation for getting into insert mode).
you don't need to press ESC before you can get to insert mode, you need to press enter (known in vim as <CR> for carriage return).
so if you wanted to find foo and start inserting text, type
/foo<CR>i
remember that <CR> is a single pressing of the enter button.

vimrc key mapping not working after the Esc key

map <Alt>q <Esc>la
This line in my vimrc seems not working after the Esc key. It do exits the insert mode but doesn't enter insert mode again. I also tried
inoremap <Alt>q <Esc>la
map <Alt>q <Esc><Ctrl-A>
map <Alt>q <Esc><Ctrl>A
Basically I want to have something within the normal typing position to have the same effect as key. Say
(i>5[cursor])
->
(i>5)[cursor]
Solution:
I figured out the problem. Its cuz my terminal doesn't properly recognize alt as the alt, instead as a system level alt somehow. see
Alt key shortcuts not working on gnome terminal with Vim
As far as I can see there are two problems:
<Alt> isn't a thing. If you want to map Alt+q, that's <M-q>.
:map doesn't apply to insert mode.
You haven't explained what you're trying to do, so I can't tell you what to do instead.

Jump out of quotes in VIM insert mode?

I'm using the delimitMate plugin to get autowrapping quotes. How can I step out of these quotes while in insert mode? Not opposed to key mapping.
While in Insert mode, press Ctrl-o(lowercase) immediately followed by A(uppercase).
You will be taken to end of current line and continue to be in Insert mode.
Hope that helps.
EDIT: In case you wish to step out of the quotes and land immediately to the right of the ending quote: while in Insert mode, press Ctrl-o(lowercase) immediately followed by f"(f followed by quotes) and then the right arrow key. You can assign a key map to this combination.

Is it possible to map <C-;> to : in vim?

I use capslock as control so it is more natural to use as : but noremap <C-;> : does not work. Is it possible to do such mapping in vim?
From Vim FAQ (also available through this nice plugin):
20.4. I am not able to create a mapping for the <xxx> key. What is wrong?
1) First make sure, the key is passed correctly to Vim. To determine if
this is the case, put Vim in Insert mode and then hit Ctrl-V (or
Ctrl-Q if your Ctrl-V is remapped to the paste operation (e.g. on
Windows if you are using the mswin.vim script file) followed by your
key.
If nothing appears in the buffer (and assuming that you have
'showcmd' on, ^V remains displayed near the bottom right of the Vim
screen), then Vim doesn't get your key correctly and there is nothing
to be done, other than selecting a different key for your mapping or
using GVim, which should recognise the key correctly.
Trying the above with <C-;> shows that it is not captured by vim/gvim...

Resources