f search navigates to wrong character when using remapping - vim

I use nvim with a German keyboard (on a Mac) and have remapped some keys to do something more useful for me. This is what that part of my init.vim looks like:
nnoremap , :
nnoremap : ,
imap ö (
imap ä )
imap Ö [
imap Ä ]
imap ü {
imap Ü }
imap ß \
nmap ß \
nmap ö /
My problem is that when I use, for example f{, it tries to find the character ü instead, and the same for all remapped characters. I tried other types of maps, but that does not seem to help.
EDIT: I also just checked on my Linux machine, and this does not seem to be a MacOS issue, the behaviour is the same there (perhaps unsurprisingly).
EDIT2: I have reduced my init.vim to just the above. The command :verbose nmap { returns No mapping found.
Furthermore, what I noticed is that if I am in normal mode and type //, below I see /ö instead -- i.e. it seems that the first instance of / is remapped correctly, but once I am inside the /-command, it is not.

Related

Using key combinations in .vimrc

imap ( ()<ESC>i
imap { {<CR> <CR>}<ESC>i<Up><Tab>
imap [ []<ESC>i
imap <S-BS> <Del>
I decided to create auto bracket and there I was a need key combination for fast delete double bracket (4 line in code). But it doesn't work. What's the problem? It work if I overwrite <S-BS> to (for example) symbol *.
When you do <S-BS>, Vim sees <BS>. To verify this, do CTRL-V then backspace or shift+backspace in insert mode. This will insert ^? for both, which is the terminal code for those special keys. See :help c_CTRL-V. So both backspace and shift+backspace have the same terminal code, which means Vim can't tell the difference between the two.
The mapping does work in gVim though.

Vim imap jk <Esc> not working

In my vimrc, I've remapped jk to escape using imap.
The problem emerges when I use jk; it doesn't escape, it only echoes out <Esc>.
Here's the entry in quiestion:
imap jk <Esc>
It's also a good point to make that I'm also using vim-X11 in fedora.
It looks like your 'cpoptions' settings contains <; then, special key codes like <Esc> are not recognized.
Find out where this got set via
:verbose set cpo?
or re-write the mapping to use a literal Escape character; enter it via Ctrl + V Esc; it should appear as ^[ in the buffer.
PS: Though not related, you should usually use :inoremap unless remapping is required.
For those who are here because of the title, the jk mapping will also not work when :set paste is enabled.

Key mapping (grave accent) and encoding issue in .vimrc

I have an odd problem with mapping in Vim. I am using an Azerty keyboard.
In my .vimrc, I have the following command to quickly move between paragraphs.:
nnoremap _ {
vnoremap _ {
nnoremap è }
vnoremap è }
However, the second mapping using è is not taken into account.
After startup, if I check the mapping, I got something for :verbose map _ but nothing for :verbose map è.
Worse, if I actually type nnoremap è }in runtime, the mapping is correctly registered.
I think this is an encoding issue, but I don't manage to find a work around.
I am using Vim 7.3 on Debian Lenny.
I am using the same .vimrc on WinXP, and it works there : the only difference is that on WinXP I am using set encoding=latin1 beforehand, while on Debian, I have not changed the default encoding which is utf-8
So basically, my question becomes why it works with encoding equals to latin1 and not utf-8 Does it have something to do with è being encoded in multiple bytes in utf-8 ?
Perhaps the .vimrc file encoding is not correct.
You can see it using set fileencoding, and change it using :w ++enc=utf-8 or :w ++enc=iso-8859-1.

gvim -- problem when imap'ing certain unicode characters

I have a few vim shortcuts to insert Greek and math characters. (for nicer looking comments and Haskell code.) Unfortunately, the "forall" character seems to insert ∀þX instead of just ∀. Does this behavior happen for you, and is there a workaround?
imap <expr> <A-a> "α"
imap <expr> <A-b> "β"
imap <expr> <A-g> "γ"
imap <expr> <A-l> "λ"
imap <expr> <S-A-f> "∀"
imap <expr> <S-A-e> "∃"
You'll have to use gvim in order to use the "Alt" key combinations; you can change the "A" to a "C" and try to use it in vim if desirable. The same error comes up for me.
(It also seems that I can't map both "alt+key" and "shift+alt+key", but I'll worry about that when it becomes a problem.)
It looks like one of the bugs related to «0x80 byte starts an escape sequence» problem: in UTF-8 ∀ is \xe2\x88\x80... you see the last byte, do you? If you want to use it you should change mapping to
inoremap <expr> <S-A-f> "\u2200"
Also note the nore: don't use *map unless you know why you prefer it to nore version, it may save you from troubles when your vimrc grows. Another option is
inoremap <S-A-f> ∀

gVim doesn't recognize the Meta (Alt) Key in an imap after changing the encoding

In order to edit html files, I have the following three imaps in a file that I source for filetype html:
imap <buffer> <M-[> ü
imap <buffer> <M-;> ö
imap <buffer> <M-'> ä
This works fine until I change the encoding of the html file with set enc=utf-8. Now, pressing Alt-[ for example gives me a Û.
Interestingly, after sourcing the same file again, it expands the imaps correctly.
This doesn't really make sense to me. So, why is this and how can I have a more constistent environment regarding imap and utf-8.
This is occuring with gVim 7.1 for Windows.
It sounds like the same problem listed here: https://superuser.com/questions/154491/utf-8-option-makes-alt-key-to-insert-accented-characters-in-vim-how-to-disable-i
I'd suggest putting set encoding = utf-8 in your vimrc above your imap mappings, rather than turning it on for specific files.

Resources