]> git.draconx.ca Git - vimconf.git/commitdiff
Fix cursor position when using colemak.
authorNick Bowler <nbowler@draconx.ca>
Thu, 26 Jan 2012 02:09:38 +0000 (21:09 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 26 Jan 2012 02:16:46 +0000 (21:16 -0500)
The langmap parameter breaks Gentoo's vimrc code to restore previous
cursor positions from viminfo.  Write a function that does not depend on
the current keyboard bindings.

plugin/keymap.vim [new file with mode: 0644]
vimrc

diff --git a/plugin/keymap.vim b/plugin/keymap.vim
new file mode 100644 (file)
index 0000000..f53735f
--- /dev/null
@@ -0,0 +1,22 @@
+" Copyright © 2012 Nick Bowler
+"
+" Set langmap based on the KEYMAP environment variable.  This allows key
+" bindings to work properly regardless of the keyboard layout.
+"
+" License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+" This is free software: you are free to do what the fuck you want to.
+" There is NO WARRANTY, to the extent permitted by law.
+
+if $KEYMAP == "colemak"
+       set langmap=sd,fe,tf,dg,ui,nj,ek,il,kn,yo,\\;p,pr,rs,gt,lu,jy,SD,FE,TF,DG,UI,NJ,EK,IL,KN,YO,:P,PR,RS,GT,LU,JY,o\\;,O:
+endif
+
+" Disable Gentoo's default cursor position handling, because it is broken wrt.
+" langmap.
+let g:leave_my_cursor_position_alone=1
+
+" Jump to last cursor position when editing a file.
+autocmd BufReadPost *
+       \ if line("'\"") > 0 && line("'\"") <= line("$") |
+       \       execute "goto" line2byte(line("'\"")) |
+       \ endif
diff --git a/vimrc b/vimrc
index 472aa4e87af97b60150760c710eab1f79b2e6782..a76c2228afeb3f40daa0e454c0d4b90b302d2246 100644 (file)
--- a/vimrc
+++ b/vimrc
@@ -6,11 +6,6 @@ syntax on
 " Try to prevent vim from seeing terminal escape sequences with user input
 set timeoutlen=100
 
-" langmaps for non-standard layouts
-if $KEYMAP == "colemak"
-       set langmap=sd,fe,tf,dg,ui,nj,ek,il,kn,yo,\\;p,pr,rs,gt,lu,jy,SD,FE,TF,DG,UI,NJ,EK,IL,KN,YO,:P,PR,RS,GT,LU,JY,o\\;,O:
-endif
-
 " Mouse Stuff
 set mouse=a
 :map <MouseDown> 5<C-Y>