2013-06-06 2 views
1

vim이 vim의 첫 번째 비어 있지 않은 문자로 이동하도록 홈 버튼을 매핑하고 싶습니다. 그러나 홈 버튼 매핑은 아무 것도하지 않습니까? 다른 키를 매핑하면 제대로 작동합니다.vimrc에서 홈 단추를 매핑 할 수 없습니다.

내의 vimrc 파일 아래 참조 :

map <Home> 0w 
imap <Home> <ESC>0wi 

은 위의 작동하지 않습니다. 다음과 같은 작업 (예 : Ctrl-F)

map <C-f> 0w 
imap <C-f> <ESC>0wi 

거기에 홈 키를 매핑하는 방법이 없습니까? Notepad ++, Sublime text 2, Visual Studio ...와 작업 할 때 익숙해 져서 정말 필요합니다.

나는 또한 다음과 같은 결과를 얻지 못했습니다. 다른 키를 사용하는 경우, 그것은 (this nice plugin를 통해서도 가능) Vim FAQ에서 http://vim.wikia.com/wiki/Smart_home

+0

당신이 어떤 매핑을 추가하지 않을 경우, 홈 키는 아무것도하지 않습니다 ... 나를 위해 작동? – mihai

+2

매핑을 시도했지만 여기에서 작동합니다. btw, 당신의'0w'은'^'일 수 있습니다. – Kent

+0

@mihai 예 ... 0w가 아닌 ​​Home 키를 사용하여 보조 정보로 – Ozkan

답변

5

... 다시 작동합니다

20.4. I am not able to create a mapping for the <xxx> key. What is wrong? 

1) First make sure, the key is passed correctly to Vim. To determine if 
    this is the case, put Vim in Insert mode and then hit Ctrl-V (or 
    Ctrl-Q if your Ctrl-V is remapped to the paste operation (e.g. on 
    Windows if you are using the mswin.vim script file) followed by your 
    key. 

    If nothing appears in the buffer (and assuming that you have 
    'showcmd' on, ^V remains displayed near the bottom right of the Vim 
    screen), then Vim doesn't get your key correctly and there is nothing 
    to be done, other than selecting a different key for your mapping or 
    using GVim, which should recognise the key correctly. 

당신이 눌러있는 home 키가 동일한 경우 확인할 수 있습니다이 방법을 빔 <Home>으로 이해하십시오.

또 다른 가능성은 다른 매핑이이 것을 방해하고 있다는 것입니다. 다음을 시도해 볼 수도 있습니다 :

noremap <Home> 0w 
inoremap <Home> <ESC>0wi 

편집 :

이 문제는 터미널이 빔이 <Home>로 인식되지 않았다는 home 키 코드를 전송하고 있음을 보인다.

나는 최선의 해결책은 Vim이 그 키를 올바르게 인식 할 수 있도록하기 위해서 당신의 .vimrc을 변경없이 다른 터미널/시스템으로 옮길 수 있다고 믿는다. :h xterm-end-home-keys에서

: 문제가 해결되지 않으면

On some systems (at least on FreeBSD with XFree86 3.1.2) the codes that the 
    <End> and <Home> keys send contain a <Nul> character. To make these keys send 
    the proper key code, add these lines to your ~/.Xdefaults file: 

    *VT100.Translations:  #override \n\ 
     <Key>Home: string("0x1b") string("[7~") \n\ 
     <Key>End: string("0x1b") string("[8~") 

, 당신은 :set t_kh=^V^[[1~을 시도 할 수 있습니다. 작동하는 경우 터미널 유형의 체크에 동봉 할 수 있습니다. 추가 정보는 :h terminal options


편집 2에서 찾을 수 있습니다

20.4. I am not able to create a mapping for the <xxx> key. What is wrong? 

: 
: 

3) If the key is seen, but not as itself and not as some recognizable 
    key, then there is probably an error in the terminal library for the 
    current terminal (termcap or terminfo database). In that case > 

     :set term? 

    will tell you which termcap or terminfo Vim is using. You can try to 
    tell vim, what termcode to use in that terminal, by adding the 
    following to your vimrc: > 

     if &term == <termname> 
      set <C-Right>=<keycode> 
     endif 

    where <termname> above should be replaced by the value of 'term' 
    (with quotes around it) and <keycode> by what you get when hitting 
    Ctrl-V followed by Ctrl-Right in Insert mode (with nothing around 
    it). <C-Right> should be left as-is (9 characters). Don't forget that 
    in a :set command, white space is not allowed between the equal sign 
    and the value, and any space, double quote, vertical bar or backslash 
    present as part of the value must be backslash-escaped. 

    Now you should be able to see the keycode corresponding to the key 
    and you can create a mapping for the key using the following command: > 

     :map <C-Right> <your_command_to_be_mapped> 

For more information, read 

    :h map-keys-fails 
    :h map-special-keys 
    :h key-codes 
+0

흠. 대답 해 주셔서 감사합니다. 나는 설명대로하고 있는데, 나는 다음과 같이된다 : 삽입 모드에서 Ctrl-Q를 누를 때 => ^. Home을 누르면, =>'^ [[1 ~'. 이것은 희망이 있다는 것을 의미합니다 :)? [[매핑을 위해 vimrc에서 [1 ~을 사용해야합니까? – Ozkan

+1

거의 -'^ ['는'Esc'입니다. map 명령을 입력 할 때 위와 같이 시퀀스를 삽입 할 수 있습니다. 이자형. '홈'을 누르기 전에 'Ctrl-Q'키를 누르면됩니다. – Armali

+0

@Ozkan은 (는) 위의 편집을 참조하십시오. – mMontu

관련 문제