tags:

views:

55

answers:

1

How to remap <Ctrl-Home> to go to first line in file? I tried the following command, but it doesn't work (environment is xterm in KDE). Vim recognises the Home key and goes to beginning of line, but looks like it doesn't recognized <Ctrl-Home> combo.

noremap <Ctrl-Home> gg
+2  A: 
  1. Vim does not know <Ctrl- modifier. It calls it <C-. Try

    inoremap <C-Home> gg
    
  2. If that does not help, then see whether there is some difference between what vim shows when you press <C-v><C-home> and <C-v><Home>, post both results here. If there is no difference, then it maybe is not possible.

ZyX
Both `<C-v><C-home>` and `<C-v><Home>` give same output as below (ie it doesnt look like it is recognising <C-Home>, only <Home> output - ^[[1~
rrp
@rrp try konsole: yakuake (which is based on konsole) gives `^[[1~` for `<Home>` and `^[[1;5H` for `<C-Home>`.
ZyX
Urxvt also does distinguish: `^[[1~` and `^[[7^`.
ZyX
Forget about it: I installed xterm and it does distinguish between `<Home>` and `<C-Home>`: `^[[H` and `^[[5H`. Problem is with your installation. Post somewhere output of `xrdb -query | grep ^xterm`.
ZyX
This is the output, though it doesnt look like it is related to any keybindings.xrdb -query | grep ^xterm xterm*background: #ffffff.xterm*foreground: #000000.xterm.SimpleMenu*background: #dcdcdc.xterm.SimpleMenu*foreground: #000000.
rrp
@rrp Is this all output? I have also things like `xterm*modifyCursorKeys: 0///xterm*modifyFunctionKeys: 0///xterm*modifyOtherKeys: 0` (/// replaces newline). Try `echo -e 'xterm*modifyOtherKeys: 0\nxterm*modifyFunctionKeys: 0\nxterm*modifyCursorKeys: 0' | xrdb -merge -`
ZyX
After above cmds my xrdb -query gives 3 additional lines \\\xterm*modifyCursorKeys: 0 \\\xterm*modifyFunctionKeys: 0 \\\xterm*modifyOtherKeys: 0 \\\But still no luck with `noremap <C-Home> gg`(\\\ means newline)
rrp
@rrp 0. Have you restarted xterm after using xrdb? 1. Before doing `noremap` check `<C-v><C-Home>` and `<C-v><Home>`. Maybe you need to tell vim that some particular sequence is `<C-Home>`. 2. If `<Home>` and `<C-Home>` still does not differ, then what distro is this? Cannot help you without trying to reproduce this on virtual machine. 3. Does `<C-Home>` differ from `<Home>` in konsole?
ZyX
1. yes restarted xterm . `<C-v><C-Home>` and `<C-v><Home>` are still same. 2. Distro is setup by my company, so not really sure. Mostly it looks some kind of custom distro. 3. Konsole same result as xterm 4. info - 'kate' text editor in my KDE is able to recognise <C-Home> easily. So issue is with only xterm/konsole. 5. I used `set termcap` command in vim and saw this combo `<C-Home> ^[05H`. I used `set <C-Home>=^[05H` in vim and used map cmd . But still no difference. (http://vimdoc.sourceforge.net/htmldoc/term.html)
rrp
@rrp My xterm also has `xterm*combiningChars: 4 ///xterm*ctrlFKeys: 12` xrdb entries. I do not think that setting this will work (at least, blanking xrdb changed nothing in `...Home>` behavior), but try setting them. What does `setxkbmap -print` show?
ZyX
@ZyX 1. set the new xterm options also. No difference. 2. `setxkbmap -print` shows XKB extension not present on hostname:1.0
rrp
@rrp Sorry, but I do not know what to do then.
ZyX
@ZyX That is ok. Thanks for all the help :-)
rrp