• You are not logged in.

Colemak + Vim

  • Started by Jules
  • 148 Replies:
  • Reputation: 0
  • Registered: 22-Nov-2009
  • Posts: 58

Hi everybody,

I've just posted a Vim script which allows you to use Colemak to type text but keep the qwerty layout for normal command.
With this script you can either be in Qwerty mode and  sometime switch to Colemak ( in insert mode)
or use a Colemak keyboard and want to switch back to the qwerty command binding.

I know that's not the best thing to do , (working with two layouts) but I m still learning Colemak and I am not efficient enough to use it at work.
With this, I can work in a qwerty environement and try sometimes to Colemak without breaking every short-cut of every application.

I hope some will find it usefull as well.

http://www.vim.org/scripts/script.php?script_id=2865

Max

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

Why so complex?  The same could easily be achieved with vim's keymap functionality, which also affects insert mode only.

See :help keymap and :help keymap-file-format.

Offline
  • 0
  • Reputation: 0
  • Registered: 22-Nov-2009
  • Posts: 58
ghen said:

Why so complex?  The same could easily be achieved with vim's keymap functionality, which also affects insert mode only.

See :help keymap and :help keymap-file-format.

You are right indeed, except :
- I haven't find (or at least easilty) a proper configuration file already map, with nice mappings so I can switch back easily to qwerty (when I need to do proper stuff at work)
- That works only if your version of Vim has been compiled with the +keymap feature, which is not the case of my version. I use the native Vim on mac os.

So, I think some people (me at least) would prefer to download a script than be bothered to compile their own Vim version. But you are right, I would prefer  the proper keymap version  too , and I might realize  I need to switch to this.


Max

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

- I haven't find (or at least easilty) a proper configuration file already map, with nice mappings so I can switch back easily to qwerty (when I need to do proper stuff at work)

It's easy, I have in my .vimrc:

" load rulemak keymap but don't switch to it immediatly.
" use the same keymap for searching as for inputting.
set keymap=rulemak
set iminsert=0
set imsearch=-1

I can switch between "normal" (colemak) and rulemak (russian colemak) by pressing ^6 (Ctrl+6), in insert mode but also in commands involving text (eg. searches).

The keymap file itself is in ~/.vim/keymaps/rulemak.vim and has a very simple format:

scriptencoding utf-8

let b:keymap_name = "rulemak"

loadkeymap
A    а    CYRILLIC CAPITAL LETTER A
B    б    CYRILLIC CAPITAL LETTER BE
W    в    CYRILLIC CAPITAL LETTER VE
G    г    CYRILLIC CAPITAL LETTER GHE
(fromkey tokey comment)

I'm using vim from pkgsrc (on NetBSD) and modified the package to include the keymap option.  It's a simple compile time option and adds no extra build or runtime dependencies.

Offline
  • 0
  • Reputation: 0
  • Registered: 09-Oct-2009
  • Posts: 23

Anyone still in here?
Since this thread has kept getting revived since 2006, i think i might as well post this.

This might or might not be related to differences between Vim versions (7.2 here), but:

WRONG:

nnoremap <silent> N @='5n'<CR>|
                        ^

RIGHT:

nnoremap <silent> N @='5h'<CR>|
                        ^

(That's from the "Turbo" section.)

Last edited by TaylanUB (27-Feb-2010 22:19:55)

``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline
  • 0
  • Reputation: 0
  • Registered: 22-Nov-2009
  • Posts: 58

Hi TaylanUB.
Just check if it was working , and it works. There is a no remap indeed but it doesn't apply as we are using @= (which simulate the use n 5 times, which what we want).

So are you sure that you fix works ?

By the way I m not using shai mapping but a minimal one :
"movement
noremap n j
noremap l k
noremap k n
noremap j e
noremap e l

which give the "FPS" movement scheme as shai's one , but shifted by one key
              l
             hne

The minimal usable mapping I found (handy where you have to do it manually , on a remote computer for example) just the 3 fisrt one
noremap n j
noremap l k
noremap k n

that gives roughly the same as before but you lose the 'right' feature. I use the space bar  for it

Offline
  • 0
  • Reputation: 0
  • From: Switzerland
  • Registered: 10-Nov-2007
  • Posts: 16
bmx007 said:

By the way I m not using shai mapping but a minimal one

Since this thread has grown that large and has become hard to overview I'd like to take the opportunity to point back to my similar post in this thread with another minimal setup.

Offline
  • 0
  • Reputation: 0
  • Registered: 22-Nov-2009
  • Posts: 58
cisum said:

Since this thread has grown that large and has become hard to overview I'd like to take the opportunity to point back to my similar post in this thread with another minimal setup.

This thread is quite large indeed, maybe we should write a summary of it (with just the final script of each different mapping) and put it somewhere, here or on vim.wikia.com.

Offline
  • 0
  • Reputation: 0
  • Registered: 05-Jan-2010
  • Posts: 91

Yes. You should. Somewhere nicely formatted.

Offline
  • 0
  • Reputation: 0
  • Registered: 09-Oct-2009
  • Posts: 23
bmx007 said:

Hi TaylanUB.
Just check if it was working , and it works. There is a no remap indeed but it doesn't apply as we are using @= (which simulate the use n 5 times, which what we want).

So are you sure that you fix works ?

How exactly did you test it?

First do: nnoremap n h
Then do nnoremap <silent> N @='5n' and see what 'N' does.
Then do nnoremap <silent> N @='5h' and see what 'N' does.

When i do it with '5n', it makes 'N' jump to the fifth next search result.
Using '5h' i get what i expect.

I've tested this carefully, and if you get different results, it must be a difference in versions.
(Using vim 7.2 (the latest) myself.)

``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline
  • 0
  • Reputation: 0
  • Registered: 22-Nov-2009
  • Posts: 58

That's really weird.
I've done exactly what you said (here is the result of the map command)

n  N           * @='5n'<CR>
n  n           * h

And when I hit N ,it goes 5 char to the left ...
Obviously If you haven't map the h, 5h will work to.

(I use Vim 7.2 on mac)

Offline
  • 0
  • Reputation: 210
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,343

I'm fairly certain it isn't about Vim versions. Most likely an effect of different remapping strategies, I suspect. I.e., in one method the 'n' may be remapped before the '5n' takes place and in another, not? I had much trouble fiddling with mapping sequence, myself (but that's because I just had to go in and tweak just about everything, curious cat that I am).

Last edited by DreymaR (01-Mar-2010 09:55:43)

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 0
  • Registered: 17-Mar-2008
  • Posts: 192

Then do nnoremap <silent> N @='5n' and see what 'N' does.
Then do nnoremap <silent> N @='5h' and see what 'N' does.

When i do it with '5n', it makes 'N' jump to the fifth next search result.
Using '5h' i get what i expect.

nnoremap does not remap recursively. Therefore, since n jumps to the next search result, nnoremap 5n should jump to the fifth search result.

If you remap n, and want to use a mapping that uses the remapped n, use nmap.

Offline
  • 0
  • Reputation: 210
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,343

You don't want search results. You want UNEI navigation.

" Up/down/left/right
nnoremap u k|xnoremap u k|onoremap u k|noremap! <M-u> <Up>|snoremap <M-u> <Up>|
nnoremap n h|xnoremap n h|onoremap n h|noremap! <M-n> <Left>|snoremap <M-n> <Left>|
nnoremap e j|xnoremap e j|onoremap e j|noremap! <M-e> <Down>|snoremap <M-e> <Down>|
nnoremap i l|xnoremap i l|onoremap i l|noremap! <M-i> <Right>|snoremap <M-i> <Right>|
" TODO: Exclusive (=not linewise) motions? (gk/gj)

" Turbo navigation mode
" Modified to work with counts, see :help complex-repeat
nnoremap <silent> U @='5u'<CR>|xnoremap <silent> U @='5u'<CR>|onoremap <silent> U @='5u'<CR>|
nnoremap <silent> N @='5n'<CR>|xnoremap <silent> N @='5n'<CR>|onoremap <silent> N @='5n'<CR>|
nnoremap <silent> E @='5e'<CR>|xnoremap <silent> E @='5e'<CR>|onoremap <silent> E @='5e'<CR>|
nnoremap <silent> I @='5i'<CR>|xnoremap <silent> I @='5i'<CR>|onoremap <silent> I @='5i'<CR>|

This has worked fine for me (Win and Linux versions of vim iirc).

Last edited by DreymaR (01-Mar-2010 12:26:54)

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 0
  • Registered: 09-Oct-2009
  • Posts: 23
bmx007 said:

That's really weird.
I've done exactly what you said (here is the result of the map command)

n  N           * @='5n'<CR>
n  n           * h

And when I hit N ,it goes 5 char to the left ...
Obviously If you haven't map the h, 5h will work to.

(I use Vim 7.2 on mac)

(Responding to all posts on this issue...)

My map command says the exact same thing (after having sourced Shai's current colemak.vim file), yet N goes to the fifth next search result. :D

I now tried DreymaR's code, and i get the same, unexpected result.

This must have something to do with compiling options, or something; can't think of anything else.

What do you guys' `:version` say?

Mine would be:

:version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 22 2010 16:08:53)
Included patches: 1-368
Compiled by ArchLinux
Big version with GTK2 GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape +dialog_con_gui +diff
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall
 +linebreak +lispindent +listcmds +localmap +menu +mksession +modify_fname +mouse +mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme
+netbeans_intg -osfiletype +path_extra +perl +postscript +printer -profile +python +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows
+writebackup +X11 -xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr
/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng14     -march=i686 -mtune=generic -O2 -pipe -D_FORTIFY_SOURCE=1    -D_REENTRANT -D_GNU_SOURCE  -fstack-protector -I/usr/l
ocal/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -I/usr/lib/perl5/core_perl/CORE  -I/usr/include/python2.6 -pthread
Linking: gcc   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,--hash-style=gnu -Wl,--as-needed -L/usr/local/lib -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpang
ocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lXt -lncurses -lacl -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -fstack-protector -L/usr/local/lib  -L/usr/lib/
perl5/core_perl/CORE -lperl -lutil -lc -L/usr/lib/python2.6/config -lpython2.6 -lutil -lm -Xlinker -export-dynamic

``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline
  • 0
  • Reputation: 0
  • Registered: 22-Nov-2009
  • Posts: 58

Mine is

:version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jun 17 2009 19:45:57)
Included patches: 1-22
Compiled by _www@b68.apple.com
Normal version without GUI.  Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search 
-farsi +file_in_path +find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv +insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent +listcmds +localmap +menu +mksession +modify_fname +mouse -mouseshape -mouse_dec -mouse_gpm 
-mouse_jsbterm -mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra -perl +postscript +printer -profile -python +quickfix +reltime -rightleft -ruby +scrollbind -signs +smartindent -sniff +statusline 
-sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim 
-xsmp -xterm_clipboard -xterm_save 
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -D_FORTIFY_SOURCE=0 -Iproto -DHAVE_CONFIG_H     -arch i386 -arch ppc -g -Os -pipe -mdynamic-no-pic -arch i386 -arch ppc -pipe        
Linking: gcc   -arch i386 -arch ppc             -o vim       -lm -lncurses  -liconv
Offline
  • 0
  • Reputation: 0
  • Registered: 22-Nov-2009
  • Posts: 58

Are you using the GUI ? Maybe that mess up the behavior of the @='5n' which would not interpreted in command mode.

Offline
  • 0
  • Reputation: 0
  • Registered: 09-Oct-2009
  • Posts: 23

Never using GUI.

Don't mind Vim talking about a "big" version; having the non-GUI Vim already installed, the gVim package is just an additional 2 MBs, and the reason i installed it is that it enables usage of the system clipboards via registers * and +.

Last edited by TaylanUB (03-Mar-2010 18:31:51)

``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline
  • 0
  • Reputation: 0
  • Registered: 22-Nov-2009
  • Posts: 58

Can you send (or post somewhere) a session (:mksession) so I can try with exactly the same mapping as you or have you tried to clear all your mappings first ?

Offline
  • 0
  • Reputation: 0
  • Registered: 09-Oct-2009
  • Posts: 23

(Phew. For a second i thought it's all my retardedness. I never deactivated the remaps in my .vimrc, BUT doing so solved nothing either (i only had a few noremaps anyway). :P Sourcing NO startup file but Shai's colemak.vim keeps causing the same unexpected results.)

bmx007 said:

Can you send (or post somewhere) a session (:mksession) so I can try with exactly the same mapping as you or have you tried to clear all your mappings first ?

OK, this is after simply using colemak.vim as my vimrc and sourcing nothing else:

http://i.imagehost.org/download/0487/tub-session

---

Here's our compilation differenced BTW...

(punBB (this forum) really needs folds (the "more" or "spoil" tags), sorry for littering up the page with the code boxes.)

You have no option enabled that i have disabled.
These are what you have disabled, and i have enabled:

+arabic
+balloon_eval
+browse
+clientserver
+clipboard
+dnd
+emacs_tags
+farsi
+gettext
+keymap
+langmap
+mouseshape
+mouse_dec
+mouse_netterm
+netbeans_intg
+perl
+python
+rightleft
+signs
+toolbar
+X11
+xim
+xsmp_interact
+xterm_clipboard

Special cases:
I have "++builtin_terms" (vs. your "+builtin_terms").
I have "+dialog_con_gui" (vs. your "+dialog_con").
I have "+startuptime".

Last edited by TaylanUB (03-Mar-2010 20:01:46)

``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline
  • 0
  • Reputation: 0
  • Registered: 22-Nov-2009
  • Posts: 58

When I try to source your file  lots of strange things happend. the normal navigation works but not the turbo one. The <Cr> are missing , so I have to type N and then enter to make it work. you should try clear all of your mapping :mapclear an mapclear! and then try again with just the navigation mapping to see what s happening.

Offline
  • 0
  • Reputation: 0
  • Registered: 09-Oct-2009
  • Posts: 23
bmx007 said:

When I try to source your file  lots of strange things happend. the normal navigation works but not the turbo one. The <Cr> are missing , so I have to type N and then enter to make it work. you should try clear all of your mapping :mapclear an mapclear! and then try again with just the navigation mapping to see what s happening.

There were non-printable control-keys in the file (which Vim prints out as ^V, ^O, ^[, etc., you know) which disappeared during copy&paste.

I now uploaded the file: http://i.imagehost.org/download/0487/tub-session
That should work.

(On the meanwhile, i did `:mapclear`, `:mapclear!` and `:so colemak.vim` and had still the same issues.)

``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline
  • 0
  • Reputation: 0
  • Registered: 22-Nov-2009
  • Posts: 58

Hi,
I tried your file and that works perfectly well. Maybe should carry on this conversation on a new thread in Technical issues.

Offline
  • 0
  • Reputation: 0
  • Registered: 09-Oct-2009
  • Posts: 23

I expected it would work in your Vim.

It's really weird but apparently even though our Vim versions are the same (except compilation, but i'm not so sure if that's even relevant), they interpret the @='' differently.

I will see if i can get some information specifically on Vim's behaviour. It's obviously not Colemak related, but if i find something useful, i'll definitely report back here.

Thanks for all the help.

``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline
  • 0
  • Reputation: 0
  • Registered: 09-Oct-2009
  • Posts: 23

(Sorry for double post but it's been 20 days.)

The following trimmed down colemak.vim is, in my opinion, a perfect minimal template.

It surely represents my personal tastes. MANY things have been removed, notably anything GUI related.
All Ctrl and Meta (Alt) related bindings, except C-{n,e,i,u} for insert mode, are gone.
edit: Screw it; removed those too. Go vi-style all the way!

I hope i didn't do any silly mistakes. I could source it and it seems to work.
edit: I did and i'm fixing more with each edit. >_<

Because <see discussion we had above>, i modified the @= stuff before uploading for you. (edit: see my post below)

I don't think i'll do many changes to what is present so far (tip: don't trust me when i say such a thing), although a lot of additions might come.
edit: At least i DID tell you not to trust me.

colemak-tub.vim (4 KB), 2010-04-03
colemak-tub-nopatch.vim (4 KB), 2010-04-03

You'll want the nopatch version if you don't have the latest patches applied to your Vim. (Not exactly sure but possibly patch 346.)

Please tell me if the files get unavailable.


edit: I forgot... Does anyone else experience painful slowdown when using noremaps? It's constant and unbearable; a tiny undo takes like 2 seconds.
later edit: Ok, it's because of 'ambiguous mapping'. For info on this issue, do `:h map-ambiguous` in Vim. Changes to the submitted file will come.
edit#92834: Was just my issue anyway. Shouldn't affect you i guess. (Tip: Check your vimrc for existing mappings.) The file should now be stable for anyone without prior mappings.

Last edited by TaylanUB (03-Apr-2010 00:28:28)

``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline
  • 0