gVim on Windows: imap does not map ç (cedilla) when read from _vimrc - vim

Weird issue here: I'm trying to avoid the Esc key to exit from insert mode. I stumbled upon this article: http://vim.wikia.com/wiki/Avoid_the_escape_key and I liked the following solution:
" Two letters.
:imap çç <Esc>
When in gVim I type:
:imap çç <Esc>
I does work. But when I try to make it default by putting it in my _vimrc file:
imap çç <ESC>
I doesn't work. It gives me no error, but does not work. Every other letter works, but it seems that specifically the letter ç doesn't.

You could write :
au VimEnter * imap çç <ESC>
in your .vimrc . au is short of autocmd and it is used to tell vim that you want to execute this one as a semicolon command. VimEnter is telling vim to execute it on startup.
The syntax is :
autocmd events pattern command
You could also see the help for autocmd

Try using the following:
Add
scriptencoding utf-8
set encoding=utf-8
at the very beginning of your vimrc.
Be sure that vimrc is saved in UTF-8 itself.

Related

How do I map <CR>/<Enter> properly in Vim

I found vimrc key remapping of / in vim-better-default plugin and added to my config.
The remapping works as expected, but this remap also causes an issue with jump using the relative number. For example, when I run 5<CR>, I need to type enter once more for it to work and it only jumps for 4 lines. The output in the bottom display is :.,.+4
I tried adding these but it did not work either.
autocmd CmdwinEnter * nnoremap <CR> <CR>
autocmd BufReadPost quickfix nnoremap <CR> <CR>
Thanks,

Why disabling mapping doesn't work in my vim editor?

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.

Vim per file mappings

I tried to put the following in my file header:
#!/bin/sh
# vim:set ts=2 sts=2 sw=2 expandtab:
# vim:map <leader>t :w\|:!./script.sh <cr>:
But Vim always complains about the map, saying that it's invalid. I also tried nnoremap with no success. What should I do to fix this (I want it in this file only)?
Modelines are only for options.
If you want this mapping only for that file, add this snippet to your ~/.vimrc:
augroup ThisFile
autocmd!
autocmd BufRead,BufNew /path/to/file nnoremap <buffer> <leader>t :w\|:!./script.sh <cr>:
augroup END
edit
It looks like you want a mapping for executing the current file. If so, you are really chasing the wrong rabbit, here, and also crashing real hard in the XY Problem wall.
You can use % as a synonym for "the file associated with the current buffer" so, assuming your script is executable, this command would execute it:
:w|!./%<CR>
Therefore, you could simply put this generic mapping in your ~/.vimrc:
nnoremap <leader>t :w\|!./%<CR>
Note 1: See :help c_% for the meaning of % and in that context.
Note 2: The bar needs to be escaped when used in a mapping, see :help map_bar.

Vim: no highlighting at startup

I am using vim together with NERDTree and MiniBufExplorer. My colorscheme is peaksea. If I start vim, no syntax is highlighted in the first buffer. The other buffers have syntax highlighted. I have "syntax enable" in my vimrc. If I type :edit the syntax gets highlighted. So I tried
autocmd VimEnter * edit
but still nothing is highlighted. Did anyone encounter a similar problem or has anyone an idea how to fix this?
I remapped F12 to redo my syntax highlighting in case it gets messed up:
nnoremap <F12> :syntax sync fromstart<cr>
Maybe you can just run it as an autocmd event in your vimrc based on reading a new buffer?
autocmd BufReadPost * :syntax sync fromstart

vimrc help : trying to map Ctrl-s to :w

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.

Resources