开发者

Reset all vim shortcuts and redefine just some of them

I want to learn to use vim. The thing is simple : I don't know any of its shortcuts. So I don't want to bother learning them, I want to define my own, for every command !

  1. Is there a way to disable all the commands, and only enable those I've set ?
  2. How to redefine the most basic commands ? like insert, move up, move left, exit insert mod开发者_开发百科e... ? I've found a lot of tutorials about specific commands, but none about the most basic ones.

Thanks

Edit : Please... Can I get a real answer, instead of "are you sure ?"

Edit 2 : The main reason for this is that I'm on a dvorak keyboard, so it's not like the shortkeys are mapped to the letters I see... This makes it difficult :p. And second, I want to be super efficient... Like mapping the up, down, left and right key to "j, k, l, ;", it will enable me to edit a file without moving my hands around. Finally, I HATE when I type a wrong key, and I don't know what vim (or any other tool) did because it was a shortcut/command but I don't know what it did because I don't know it yet. And why learn shortcuts when you can make your own, that you can remember better... I'm french so some letters are not mapped in my mind like it would be for english speakers.


There's an entry on the vim wiki on wikia for Using Vim with the Dvorak keyboard layout and there's a thread on SuperUser that discusses whether or not it's worth trying to use Dvorak with vim

The sentiment in both (the comments on the wiki entry and the comments/answers on the SU conversation) seem to indicate that Dvorak and vim don't really go together very well, and I'm inclined to agree.

Other than hjkl, however, most commands should still make sense from a mnemonic standpoint, shouldn't they? And since the only real reason to use Dvorak is to increase your speed, why would you be phyiscally looking at the keys to determine what to hit?


I would strongly suggest not trying to redefine the commands. You'll be much better off learning the commands that are provided, and adding custom commands if you find something you want to do that does not exist.

If you don't like the commands, why not try a different editor?


It is possible to purge only that shortcuts that were defined using *map, built-in commands are overridable, but not purgable. If you need to disable particular command you will have to do noremap <Key> <Nop>, the following code should disable them all (but note that it is overriding, not removing anything):

function s:hsescape(str)
    return substitute(substitute(substitute(substitute(a:str,
                \      ' ', '<Space>',         'g'),
                \      '|', '<Bar>',           'g'),
                \     "\n", '<CR>',            'g'),
                \'\c^<\%(buffer\|silent\|expr\|special\)\@=', '<LT>', '')
endfunction
for s:mode in ['n', 'x', 'o']
    for s:char in map(range(0, 0x7F), 'nr2char(v:val)')
        execute s:mode.'noremap '.s:hsescape(s:char).' <Nop>'
    endfor
endfor
for s:mode in ['s', 'i', 'c']
    for s:char in map(range(0, 0x3F), 'nr2char(v:val)')
        execute s:mode.'noremap '.s:hsescape(s:char).' <Nop>'
    endfor
endfor

Note that this should be immediately followed by code that defines some mappings (or removes some of <Nop> ones) or you will render your vim useless.


I took references from the answer by ZyX and created a vimrc setup for overriding - and have tried to document the process and the functions. Hope it is helpful to someone else:

https://github.com/hiway/po

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜