Using a spanish keyboard layout like this one:
(source: terena.org)
I'm trying to map in my .vimrc the ñ to : in normal mode and the º in the upper left corner to <esc> in insert mode but it is not working. I've tried with imap and inoremap on my .vimrc like:
nnoremap ñ :
inoremap º <esc>
I've tried with Vim 7.4 both on Linux and Windows (gvim on Windows). The odd thing is that if I do the remaps in normal mode instead of in the .vimrc file, they work. It's like these chars are treated differently inside the normal mode command line, in fact after loading the .vimrc a :nmap ñ returns "No mapping found".
You can check my current .vimrc here: https://github.com/juanjux/My-Vim-dir/blob/master/.vimrc
DavidEG gave me a hint that led me to the working solution.
Comment or remove any set encoding= lines in the .vimrc file
Restart Vim
Add the maps to your .vimrc file. Save.
Uncomment the set encoding= lines.
This worked for me on Linux and Windows.
Related
In my vim editor, I can find two mappings of through following commands:
:imap <CR>
and it outputs:
i <CR> &#<SNR>60_AutoPairsOldCRWrapper73<SNR>60_AutoPairsReturn
i <CR> <CR><Plug>DiscretionaryEnd
I want to disable the first one, so I add it into my .vimrc file:
iunmap <buffer> <CR>
but vim shows error no such mapping error when I open my editor, but actually I can disable the mapping by typing command in editor:
:iunmap <buffer> <CR>
I want to know why I cann't make it work in my .vimrc configuration file.
Plugins are sourced after your vimrc so the mapping you want to disable is not defined when that comand is executed.
That said, the plugin's README tells you how to replace the default mappings. So… read it and experiment.
The tutorial gives this example:
<leader>c$ |NERDComEOLComment|
Comments the current line from the cursor to the end of line.
But pressing \c$ or ,c$ in vim copies the current line and switched to insert mode.
I've installed the plugin via pathogen and :help nerdcommenter does work, but there's no mention of nerdcommenter in the output of :scripts, don't know if that means the plugin hasn't been successfully installed.
This looks fine. Here are some troubleshooting tips:
Check the :scriptnames output for .../plugin/NERD_commenter.vim; it needs to be there.
Check :echo loaded_nerd_comments
Check :echo g:NERDCreateDefaultMappings
Check :nmap <Leader>c
Do other mappings work? Define :nmap <Leader>x :echomsg "Works"<CR> and press \x.
If mappings don't work, you may have accidentally :set paste. Undo with :set nopaste.
I am trying to map the '-' key to move a line down
in my vimrc I have
noremap - :m .+1 <cr>
but the carriage return is ignored and displayed in the terminal as <cr>
After reading Vim ignores <cr> i tried adding an additional <cr> but that just echoes the characters twice.
So after pressing the '-' key I have to physically press the <enter> key to get the command to run.
I have tried this in mac and linux and get the same results.
It works if I set nocp.
I haven't come across any instructions that this must be set for <cr> to work.
So this is the issue.
set nocp is set if a vimrc is detected.
if you are testing a custom vimrc and starting vim with vim -u mycustomvimrc then despite the fact it is loading a vimrc file it does not set nocp and maintains backward compatibility. In such cases you need to set nocp explicitly.
Thanks for all the suggestions to get this resolved.
When I use the arrow keys in vim in insert mode I get letters inserted instead of movement.
Up produces an A
Down produces a B
Left products a D
Right produces a C
Does anyone know what would cause this?
Thanks in advance
If these keys work fine in normal mode, but do not in insert then you must have some mappings to the first one or two characters (normally <Up> is either <Esc>[A (terminals that use CSI) or <Esc>OA (xterm)). Try checking out output of
verbose imap <Esc>
, there should be not much mappings starting with <Esc> in insert mode (I have none, for example). I can say, that with arrow keys working normally in insert mode, using
inoremap <Esc> <Esc>
produces just the same behavior as if you had problems with terminal recognition or had 'compatible' set.
Your vim seems to be starting in the vi compatibility mode. Do this
Open Vim editor,
Get the path of your home directory by typing :echo $HOME
Check if you have .vimrc file in $HOME location,(if you don't have create it)
Add the following line line to .vimrc file
:set nocompatible
Find more solutions for the same problem here ( Especially if your problem is terminal related, the re-mapping of keys solution might work for you )
The following worked for me. Just put it in your .vimrc
:set term=cons25
Open Vim editor.
Get the path of your home directory by typing: :echo $HOME.
Check if you have .vimrc file in $HOME location, and if you don't have create it.
Add the following line line to .vimrc file: :set nocompatible
Reference: http://vim.wikia.com/wiki/Fix_arrow_keys_that_display_A_B_C_D_on_remote_shell
None of the answer here worked for me. I'm in Linux, with konsole/yakuake terminal and tmux. This fix works for me:
nnoremap <silent> <ESC>OA <ESC>ki
nnoremap <silent> <ESC>OB <ESC>ji
nnoremap <silent> <ESC>OC <ESC>hi
nnoremap <silent> <ESC>OD <ESC>li
inoremap <silent> <ESC>OA <ESC>ki
inoremap <silent> <ESC>OB <ESC>ji
inoremap <silent> <ESC>OC <ESC>hi
inoremap <silent> <ESC>OD <ESC>li
My current .vimrc file is
syntax on
colorscheme zellner
set nu
set ruler
set si "Smart indet
map <C-s> :w<cr>
I thought the last line would allow me to hit control-s to automatically save while in normal mode?
{
The last line is just the trim downed version of what I really want which is
map <C-s> <esc>:w<cr>a
}
Am I forgetting something?
I'm using vim 7.3 that came with my mac.
Like mentioned if you want it on both modes you have to just put
inoremap <C-s> <esc>:w<cr>a
nnoremap <C-s> :w<cr>a
in your .vimrc.
But note that if you are using the terminal vim then you might have a problem
mapping ctrl-s. By default it stops the flow. In that case add the following to your .bashrc (not sure if the same problem in zsh):
stty -ixon
If I got it right, you want
:inoremap <C-s> <esc>:w<cr>a
Whoops, just read you want it in normal mode
:nnoremap <C-s> :w<cr>
When you're writing commands in vim files (like .vimrc) you don't need the :. It is only a method of entering commands on the command line.