I am on Ubuntu. I am a beginner user of Vim. I have setup key mappings in /etc/vim/vimrc
for home and end keys.
It is working on terminal, but when I edit a file in Guake terminal these mappings are not working. I have this problem with me this time only. Last time (I mean before reinstalling Ubuntu) it was working fine on each terminal.
I have tried
set term=xterm
but its still not working.
It will be really nice if someone help me with this. Also if someone can give me addition info about some other keys to map or some other things useful, it will be really nice.
--
vimrc:
if has("syntax")
syntax on
endif
//just this has been added by me
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
map <ESC>[8~ <End>
map <ESC>[7~ <Home>
imap <ESC>[8~ <End>
imap <ESC>[7~ <Home>
All the ret things are commented
I would like to add that i don't think that this is the problem with vimrc file as this configuration let me use these END and HOME keys in terminal while I'm in Insert mode or Normal mode. But not working on guake.(correct me if I am wrong please.)
Still hoping you might help me with something now.
--
When you press <C-Space> , the terminal sends an ambiguous signal to Vim which interprets it as <Nul> . Because <Nul> is usually represented as <C-@> , Vim acts as if you actually pressed <C-@> and tries to insert the previously inserted text.
In vim, control-left and control-right are back and forward whitespace-separated word (i.e. synonyms for B and W), the same as web textareas and bash . But when running screen , these keys stop working. When pressed, vim instead switches to its command line and enters 5C or 5D there.
vim file is used, then CTRL-V is mapped to paste text from the clipboard. In this case, you can use CTRL-Q or CTRL+SHIFT+V instead of CTRL-V to escape control characters. To create a map for the Ctrl-v key, you have to enter it four times: :imap ^V^V^V^V EscapeCharacter.
In vim you can reach the end of the current line using $ and the start of the line using ^. I find these characters more comfortable than Home and End when typing.
Hope it helps :)
-dave
Try adding
set term=xterm-256color
to ~/.vimrc
This happens because pressing the home and end keys in a terminal sends an escape sequence consisting of several characters to vim, and vim isn't correctly associating these escape sequences back with the keys you pressed.
Answer taken from here https://stackoverflow.com/a/1523821/5506988
I don’t know if this is going to work for you, but it worked for me: I’ve noticed that TERM was set to “linux” [check with ‘echo $TERM’].
Then there are two ways of resolving.
First) Change .bashrc or your custom config file to:
export TERM='xterm'
or Second) Add these lines to your .vimrc:
" Fix home/end key in all modes
map <esc>OH <home>
cmap <esc>OH <home>
imap <esc>OH <home>
map <esc>OF <end>
cmap <esc>OF <end>
imap <esc>OF <end>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With