• You are not logged in.

    The "give me h, j, k and l back" vim/tmux/mutt/zsh remappings

    • Started by iamthebest
    • 11 Replies:
    • Reputation: 0
    • Registered: 21-Mar-2011
    • Posts: 11

    I've added my colemak mappings to github. There are instructions on how to install them on the github page at:

    https://github.com/tuxjay/colemak

    Most keys are in their colemak positions, few are in qwerty and only one is in neither. I've been using and perfecting this mapping since I started with colemak and I find it very good.

    Note that the vim remapping also works for pentadactyl/vimperator.

    Last edited by iamthebest (23-Mar-2011 12:14:20)
    Offline
    • 0
    • Reputation: 2
    • From: Aalborg, Denmark
    • Registered: 18-Feb-2011
    • Posts: 166

    Again, thanks for these mappings.


    Shouldn't nnoremap I U be nnoremap I L? (there's already one 'U' and no 'L')

    And I personally don't use keyword lookup, but what about noremap E K for completeness?


    I'll skip the control mappings though since they hide existing functions that I use often:
    imap <C-n> <cr> hides word completion forward.
    nmap <C-l> :tabprev<cr> hides redraw.
    nmap <C-u> :tabnext<cr> hides "up".
    imap <C-u> <Esc>:tabnext<cr>i hides readline kill.

    Btw, for tabs I use
    nnoremap ,<tab> gt
    nnoremap m<tab> gT

    Behind the comma I have a whole new world of mapping, including restoration of the original comma-functionality:
    noremap ,, ,

    Offline
    • 0
    • Reputation: 0
    • Registered: 21-Mar-2011
    • Posts: 11
    erw said:

    ...

    Thanks for the comments about L/U E/K I've fixed that in git now.

    I moved ctrl-U and ctrl-L back to their default mappings now.

    Readline kill I never use when "Alt + C" does exactly the same thing and feels more vim-like... ctrl-U is kinda useful though, but since I tab more I'm putting it in my personal config only.

    Last edited by iamthebest (19-Apr-2011 19:07:34)
    Offline
    • 0
    • Reputation: 2
    • From: Aalborg, Denmark
    • Registered: 18-Feb-2011
    • Posts: 166

    Yeah, my vim style is actually a hybrid of vim and readline:

    cnoremap <c-a> <Home>|         " hides insert-all-matches
    noremap! <c-f> <Right>|        " hides cedit (c)
    set cedit=<c-g>                " restores cedit
    noremap! <c-b> <Left>
    noremap! <c-d> <Del>|          " hides dedent (i) and show matches (c)

    <c-e> is already "goto end" on the commandline, but I don't map it in insert mode because it would hide "insert character from below".

    It's a mess, but it works nicely for me  :-D


    And you're right, Alt + C is equivalent to readline kill-line (delete to eol), which is not available from within vim (<c-k> is used for digraphs). What I meant is apparently called unix-line-discard (delete to bol, which is what <c-u> does).




    I've switched from :mapping to langmap so the new keys also work in combinations such as "ge", "gj", "gk", "<c-w>H" (/J/K/L)...

    set langmap=kn,KN,nj,NJ,je,JE,ek,EK,lu,LU,ui,UI,il,IL


    EDIT: Ah, I just saw you also mapped the window movements back. But there are still "ge", "gj", "gk", "zj", "zk" and others.


    EDIT2: Hmmm... langmap has disadvantages as well. The "inner" text object command ("cip" ~ "change inner paragraph") is changed, and that's confusing :-/

    Last edited by erw (25-Mar-2011 00:01:59)
    Offline
    • 0
    • Reputation: 0
    • Registered: 21-Mar-2011
    • Posts: 11

    langmap sucks. It totally messes up mappings for example.. you end up with "P" in place of ":" in your macros for example.

    I removed the ctrl-u/l tab switching remaps from git.

    Last edited by iamthebest (19-Apr-2011 19:06:12)
    Offline
    • 0
    • Reputation: 2
    • From: Aalborg, Denmark
    • Registered: 18-Feb-2011
    • Posts: 166

    Yeah, I discovered that as well.

    And what I said about text objects doesn't matter because in visual mode I still need to move the cursor AND use text objects, so "inner" will have to be moved from "i" anyway.

    I decided to only swap "i" and "l" and let "u" be "u". I'm not trying to keep the original locations for the sake of qwerty, just for the sake of easy access, so there was no reason for me to swap the functions of the colemak letters "l" and "u".

    This is what I'm at now:

    (removed, see next post)

    Last edited by erw (31-Jul-2011 01:44:13)
    Offline
    • 0
    • Reputation: 2
    • From: Aalborg, Denmark
    • Registered: 18-Feb-2011
    • Posts: 166

    For reference, I added mine here: https://bitbucket.org/erw/colemak/src

    Offline
    • 0
    • Reputation: 0
    • Registered: 18-Jul-2011
    • Posts: 3

    Hi!
    I'm trying to get used to vim with colemak layout. I'm using erw's layout, and have a few questions.
    1. how can I remap the keys used in man and less commands. They seem to use vi mapping and don't honor .vimrc. And in bash vi mode.
    2. is it possible to use the same movement keys (jkhl, word/sentence/para movement) in edit mode, say with an alt mod?

    Last edited by vangop (22-Jul-2011 14:24:46)
    Offline
    • 0
    • Reputation: 2
    • From: Aalborg, Denmark
    • Registered: 18-Feb-2011
    • Posts: 166
    vangop said:

    Hi!
    I'm trying to get used to vim with colemak layout. I'm using erw's layout, and have a few questions.
    1. how can I remap the keys used in man and less commands. They seem to use vi mapping and don't honor .vimrc.

    You can use the file by iamthebest: https://github.com/tuxjay/colemak/blob/master/less
    Stick those lines in any file, then run $ lesskey the_filename. (this will generate the ~/.less file). As long as less is used as manpager (which is common, I think) it will also apply to manpages.

    vangop said:

    And in bash vi mode.

    Have you tried google? :-)

    I got this as the first hit: http://www.linuxforums.org/forum/applic … -mode.html

    vangop said:

    2. is it possible to use the same movement keys (jkhl, word/sentence/para movement) in edit mode, say with an alt mod?

    I assume you mean insert mode in vim. There are many possibilities. <c-o> lets you execute a single normal mode action without returning to normal mode, so for a single "move to the beginning of the next word/WORD/sentence/paragraph", you can use <c-o>w, <c-o>W, <c-o>), <c-o>], resp. You get the picture.

    You could also use

    noremap! <esc>h <left>
    noremap! <esc>n <down>
    ...

    because alt+some key is the same as esc then that key in the terminal, but that would make leaving insert mode "laggy" because a normal escape also make vim wait to see if the next key is a h, n, e, i etc.

    Offline
    • 0
    • Reputation: 0
    • Registered: 18-Jul-2011
    • Posts: 3

    Thanks a lot for the reply, now I have all vi-ish apps in a consistent colemak state.
    The <esc> mapping seems to work great, I didnt notice any lag, but I'm a vi novice, so can't be sure. It just seems too much typing to ctrl+c from insert to normal and back just for basic navigation.

    Offline
    • 0
    • Reputation: 2
    • From: Aalborg, Denmark
    • Registered: 18-Feb-2011
    • Posts: 166

    No problem!

    vangop said:

    The <esc> mapping seems to work great, I didnt notice any lag, but I'm a vi novice, so can't be sure.

    Sorry, you shouldn't experience anything weird - it's just because I use set "notimeout", which is not default.

    vangop said:

    It just seems too much typing to ctrl+c from insert to normal and back just for basic navigation.

    If you also use A, I, o and the like to enter insert mode it's not that bad, ime. But as I showed earlier in the thread I also use the readline-like shortcuts, especially <c-f> and <c-b>.

    Offline
    • 0
    • Reputation: 23
    • From: Belgium
    • Registered: 26-Feb-2008
    • Posts: 480
    erw said:

    I assume you mean insert mode in vim. There are many possibilities. <c-o> lets you execute a single normal mode action without returning to normal mode, so for a single "move to the beginning of the next word/WORD/sentence/paragraph", you can use <c-o>w, <c-o>W, <c-o>), <c-o>], resp. You get the picture.

    That's the cool thing about vi(m), even after using it for 10 years, you keep learning features/tricks you didn't know. :-)

    (this one is vim only though)

    Offline
    • 0