• You are not logged in.

Colemak + Vim

  • Started by Jules
  • 148 Replies:
  • Reputation: 0
  • Registered: 07-Aug-2007
  • Posts: 69

If you were quite deliberate in not wanting to change g, why then change the definitions on keys that stayed put going from QWERTY to Colemak, e.g., a z w c v?   They were just fine in QWERTY, or do you not believe that vim normal mode in QWERTY is quite good, indeed optimal?

I find z for undo especially pessimal for a text editor.   It is much inferior to sticking with u.   Did you choose z  because it mnemonically refers to C-z for undo in other programs?   To a vi user, that is poor consolation as he struggles to scoot his weak pinky to the south-west to effect an undo.

Moving the visual-mode key from one stay-put letter v to another stay-put letter a is equally bizarre.   Not changing their behavior would have been a win on two counts:  (1) The mental association of letter and meaning hasn't changed, and (2) The physical association of finger and meaning hasn't changed either. 

You have also irretrievably lost ALL the text objects of vim! Things like "ib" for "everything in the nearest enclosing parens" or "ip" for "current paragraph" -- gone!  These cannot be re-defined on other keys (:omap can only define motions).  I don't see what the solution is, since you seem committed to remapping i and a.  It is possible that you do not use text objects yourself, so don't really see a need for them.   However that undercuts the general-purpose utility of the plugin.

colemak.vim suffers from trying to satisfy two goals:  Only one of them is of relevance to a vim user: To have vim normal mode as usable on Colemak as on QWERTY.  The other goal, to emulate the keyboard shortcuts from non-vi programs is not going to help those who value vi for vi's own merits.   Unfortunately, that this second goal exists is not made clear. 

I have already mentioned that colemak.vim invalidates huge swaths of the vim help text, the one crutch that every vim user, whether newbie or expert, has come to lean on.   Learning colemak.vim is also no help for those who use their shell with "set -o vi" -- they still have to know true vi for that and any number of other programs that allow you to use "vi-style" keys, like Info or lynx.  I know, it can't be helped, but even so, you could have made the difference and the pain minimal.  Instead, colemak.vim makes rather lavish changes, and the changes aren't even always better than just sticking with the original vim mappings, even with the Colemak layout.   Lavish changes that break everything are fine for individual tinkering,  but they should not be offered as the canonical vim plugin for use with Colemak.   The FAQ entry is misleading.  This is a tougher problem than the FAQ entry with its blithe assurances about "total redesign" and "many advantages" would have one believe.

I notice you are fond of offering a "whole picture" rationale for the changes you propose.   I would find that persuasive, except that I can't see what the whole picture gain is here.  colemak.vim offers a very pessimal normal mode on the whole, so I don't see the point of the sacrifices entailed for each individual keymap change.

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

First of all, let me clarify that Colemak.vim is still experimental and is still under development. Indeed I never used inner text objects, and many times, the same editing functions can be the done in the similar amount of keystrokes without them. e.g. an alternative to dip (delete inner paragraph) would be {d{ . That functionality isn't irretrievably lost, it's just missing from the current version of Colemak.vim. To add it, you just need to add a relevant onoremap command, e.g. onoremap r i| , and then type in normal mode drp (update: added to the latest version of Colemak.vim)

Better documentation for Colemak.vim would definitely be helpful, but it is bound to be different from the normal mapping. Again, I think it's a sacrifice that's worth making.

One of the design goals is consistency with itself, and consistency with modern desktop shortcut guidelines. Specifically, in GVim, there are two ways to copy and paste text. One using Vim's buffer, and the other using the operating system clipboard. In Colemak.vim it is designed that both methods are consistent with one another. In this case it wasn't designed for compatibility with Vim, but for consistency with the operating system and taking into account that there are two similar ways.

Visual mode was moved to A because it's a frequent command that deserves a spot on the home position, and to be consistent with the Ctrl+A shortcut (Select All). Specifically the Insert and the Append command on Colemak.vim are based on keyboard positions, not on mnemonics. Both are very frequent commands that deserve a place on the strong fingers on the home position. You'll also notice that Insert is to left, and Append is on the right, which is also consistent when you press Shift+S (Insert to beginning) and Shift+T (Append to end) in Colemak.vim. In the QWERTY version pressing the Shift+A on the leftmost part of keyboard, adds to the rightmost part of the line, which isn't very logical to me.

Again, Z for undo is designed for consistency, but also to make it more intuitive to redo (Shift+Z). U is used for navigation, so it's given a better spot, because navigation is much more frequently used than undo. Also remember that mappings in Colemak.vim try to be consistent between modes, and all the aforementioned shortcut such as Ctrl+Z/X/C/V/A will work also in Insert mode (though to select stuff, you'll have to load the mswin.vim script).

I think the UNEI (IJKL on QWERTY) navigation in Colemak.vim makes a lot more sense than the HJKL used in the original Vim, and that required a chain of changes that eventually required almost a complete redesign. Remember that Colemak.vim doesn't only move things around, but adds mappings that weren't originally there (e.g. PageUp/PageDown functionality via the J/H keys), meaning that some functions had to be sacrificed because there's a limited amount of keys.

Many of the keys in Colemak.vim are designed by position, not by mnemonic. The W was moved but it makes a lot more sense in its new position as part of the the navigation block.

Some people that tried Colemak.vim said they liked it. Other people have suggested some less invasive mappings that might better suit your needs. Since you seem to be an expert Vim user, it may take some time for you to get used to it, and the advantages to become apparent.

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

ds26etc: If you don't like this, then don't use it (yet). As Shai says, it's an attempt and at the development stadium. As it becomes more stable, there will be documentation. So stop fussing please.

You're dead wrong if you believe that consistency with other editors/systems is of no help to "those who value vi for vi's own merits". Sure, it won't help those who live in an all-vi world and have done so for a while. But there are other people around. I'm one - I'm new to vim and Linux/Unix and I greatly value the attempt at making vim a bit less byzantine so that learning it will be less of an undertaking not only for myself but also for other new users.

Looks like those inner text objects better get back in there? It's harsh to lose good functionality.

*** 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-Apr-2007
  • Posts: 11

I was just getting used to ; for z.  I'm not sure that getting rid of z is the best idea.  I understand that ; is a faster shortcut for :, but z is used a lot for folding (which is very useful in code) and keeps getting attached to newer things like spelling.  Right now I'm just commenting out the ; shortcut for :, but I'd be open for other suggestions.

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

I tried to fix the unupdated part of the in-file documentation:

" (nv  )    u =Up          ,     n =Left         ,     e =Down         ,    i =Right
" (nv  )    U =Up*5        ,     N =Left*5       ,     E =Down*5       ,    I =Right*5
" (  ic) <M-u>=Up          ,  <M-n>=Left         ,  <M-e>=Down         , <M-i>=Right
" (  ic) <M-U>=Up*5        ,  <M-N>=Left*5       ,  <M-E>=Down*5       , <M-I>=Right*5
" (nv  )    l =Left 1 word ,     y =Right 1 word ,    ; =End of word
" (nv  ) <C-l>=Left 1 WORD ,  <C-y>=Right 1 WORD
" (nv  )    L =Home        ,     Y =End                   
" (nv  )    j =PageUp      ,     h =PageDown              
" (nv  ) <C-j>=File start  ,  <C-h>=File end
" (nv  )    - =First line  ,     _ =Last line,  <count>-=Goto line #
" (nvi )         <Tab>=Escape  (also stops search highlight in normal mode)
" (   c)       <S-Tab>=Escape
" (nvi )       <S-Tab>=Tab
" (nvic)       <Space>=Space
" ( v  )     <S-Space>=Undo space

That about right, Shai?

I still don't see a reason for the line remapping f to f and F to F?

And I still think you should make some of the overridden remappings more sensible. I suggest using gz (or gZ?) for U, and as mentioned I think gh would be better than gK - if it isn't already taken. Or, hell, why not implement both gh AND gK? That should be possible?

Last edited by DreymaR (09-Jun-2008 13:46:53)

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

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

Still no response to the documentation fix? It's a minor thing, but please consider adding it soon. Also consider the other questions in my previous post.

I miss the Z_ command. It's a superfluous way of quitting but a damn handy one for users who open and close docs all the time like I do. As a new Vim user who sees the ZXCV behaving more like I expect them to, I also expect Q to do something quit-related. I therefore suggest mapping QQ to ZZ (Save&Quit), Qq to ZQ (Quit w/o save), Q to : to keep the ex cmd and ex mode on the same key (nice!), and ... uhhh ... I realize that this is getting radical but I'd actually like to have the repeat and reverse tTfF on comma/period so they're placed next to each other (or at least on the same key). If so, the repeat cmd is in need of a new home and we're loath to use up the \. Not sure about where it should go.

A less dramatic approach would be to make gq and gz behave like ZQ and ZZ. Or, to keep the z key to the undo/redo theme now, using gq and gQ. The g mappings are the saviours of remaps!  :)

Was there ever a good reason to use both z and g for extra commands in Vim when neither of them have a lot of mappings to them? Seems like a waste to the untrained eye.

Or, hang on - you have a strategy for Quit (and Save) already, based on Ctrl-W, don't you? Jog my memory please. Do the Ctrl-mappings of this kind work in all modes (as I rather think they ought to)?

Last edited by DreymaR (09-Jun-2008 13:49:50)

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

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

I've fixed it already, but forgot to upload the new version. I'm not a big fan of ZZ to quit settings, because it's too easy to hit accidentally. I think that there are enough ways already to quit, either :q or Ctrl-W. There are loads of commands for both the z and g command, see « :h g » and « :h z ». The problem with moving tTfF to comma/period is that < and > are already used for indenting, and I'd like to keep them in place.

It is mentioned in the comments, but the "savior for remaps" is the comma key, which has been deliberately left unmapped for any user mapping that you might have.

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

Okay, thanks for the answer. I see your point about ZZ, although I've never hit it erroneously myself. What I'm most interested in, is having a way to close a document quickly without saving it. Is this what Ctrl-w does? If not, might Ctrl-Q be added for doing just that? (I think you've mentioned Ctrl-Q but if so I don't quite know what it does.)

I'm not too keen on moving the tTfF keys to comma/period, either. I see now that you've put the tTfF functions together perfectly (on the 'b' key). Nice.

I see that you added the extra mapping 'gh K' - thanks for that. Could you also please put in a 'gz U' mapping, to make the Undo key easier to remember?

Last edited by DreymaR (11-Jun-2008 11:13:12)

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

Offline
  • 0
  • Shai
  • Administrator
  • Reputation: 36
  • Registered: 11-Dec-2005
  • Posts: 423

The gz->U mapping has already been added there as well.

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

Ah, my bad. I forgot there was a whole Undo/Redo section up there, and looked only at the "extra remappings". The colemak.vim is a largish file now - full of sundry goodness.  :)

[edited out a misunderstanding about broken commands, due to my running mswin.vim AFTER colemak.vim...]

Another thought: The old Q for ex mode sits oddly, and should've been linked to the ex cmd key. I suggest an extra remapping for 'g; Q' since we're now using ; for ex.

However, what's this about the z commands being lost? We can't have that, that's for sure! If we don't want to use up the comma there are several other free or potentially free keys to take from such as '+' or '0' (I think?); the tilde is tricky on my keyboard although I'm planning to fix that (it's only available as a deadkey in the standard Scandinavian layouts).

I notice how much I'm starting to like Vim now: I'm getting annoyed at not being able to navigate with UNEI in my web browser!  :)  Maybe it's time to get some Vimperatorial action going, heh.

Last edited by DreymaR (17-Oct-2008 16:17:08)

*** 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: 06-Aug-2008
  • Posts: 15

Update. I posted my up-to-date approach along with consistent configs for Zsh, Tmux, Less, and Pentadactyl [Vimperator] in a new thread here!

Last edited by bunnyfly (15-Jan-2014 07:06:55)
Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

YACVR? No comment, sorry. Back to Shai's remappings:

- I really think you should separate the file into two files or at least two very clearly marked sections. One with the Colemak/UNEI-related mappings, and one with the specials and doodads like the line reordering and tabs and whatnot. That way, the distinction between the "colemak.vim" and the "shai.vim" will be much more clear for newcomers and the "shai.vim" part will be easier to evaluate and/or implement separately for seasoned users.

- I think the J(oin lines) should be moved somewhere (my suggestion is 'Merge') so that the jluyhnei keys forms a perfect navigation block. Also, I'm not sure whether the Top-Middle-Bottom functionality is conveniently placed anywhere or forsaken?

- What are the unused keys now (normal and shift state)? I'm working on the help images, and I'm not altogether certain about this.

Last edited by DreymaR (25-Aug-2008 16:40:41)

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

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

Dont' get me wrong - I'm loving almost all of the "Shai" improvements myself. I'm just thinking that the separation should be crystal clear so it's easier for, say, the likes of ds26gte to evaluate the changes separately. I think it'll aid acceptance if that bit is more clear.

Fun story of the day: I've become addicted to the UNEI block, to the extent that I'm starting to miss it everywhere else! Particularly when web browsing and suchlike, but also in other apps whenever text browsing is involved. So I turned to my trusty AutoHotkey "to see wha' I could dae". I came up with a chorded solution: Pressing Ctrl+Win turns JLUYHNEI into nav keys. If you use Portable Keyboard Layout I think you can do something like that with the "extend key" but I never used that myself; at any rate this is a very simple little hack. (I strongly suspected that very similar things have been done and redone before too, but this time it's colemak.vim-inspired!)

In colemak.vim we have l/y for word, L/Y for home/end and j/h for PgUp/PgDn. Now, the home/end aren't the same as the Windows Home/End keys, so those go to J/H instead. And instead of word movement, I'm sending Ctrl-arrows which results in WORD movement. You should still be able to use Shift with that to select text though!

I even went crazy and added a little browser navigation using Ctrl-Win-Alt (see below).

Try http://folk.uio.no/obech/Files/Keyboard … vBlock.zip for the script and a compiled .exe (which your virus program will likely hate simply because it's AutoHotkey!), or read the same script here:

;
; AutoHotkey Version: 1.0.47.06
; Language:       English
; Platform:       Win9x/NT
; Author:         Øystein "DreymaR" Gadmar, 0808
;
; Script Function:
;   In colemak.vim, the JLUYHNEI key block navigates around. This script attempts to make that universal!
;   (See https://colemak.com and https://forum.colemak.com/viewtopic.php?id=50 for more info.)
;   (Note: If you use another layout, the script may still work unless you've remapped at the scan code level.)
;   With Ctrl+Win, the keys work as in colemak.vim for navigation. You could hold down Ctrl+Win with one finger.
;   This way you won't have to reach for that far-away arrow key block and can stay at the home position.
;   
;   The Colemak unei/UNEI keys (QWERTY ijkl/IJKL) will send arrow key presses; 5 at a time with Shift.
;   The l/y (u/o) keys go back/forwards one word (by sending Ctrl-Left/Ctrl-Right). With Shift, select as usual.
;   The j/h (y/h) keys send PgUp/PgDn, and J/H send Home/End. (If you'd rather have L/Y, uncomment those lines.)
;   
;   The n/e/i (j/l/k) keys with Alt allow browser navigation by sending Alt+Left/Home/Right.
;   The l/u/y (u/i/o) keys with Alt send F5 (refresh), Esc and F11 (full scrn) - hopefully useful when browsing?
;   
;   Potential problems:
;   - The Win-U (Utility Manager) and Win-E (Explorer) hotkeys might be trigged accidentally,
;     and the Win menu may pop up. (I don't want to use Ctrl-Alt, as it interferes with AltGr functionality.)
;     It shouldn't be a big issue, as the menu triggers on KeyUp and Ctrl-Win are pressed before the other keys.
;   - The Win and Ctrl keys could get stuck if an app gets quarrelsome - I had trouble with GVim!
;     This can usually be fixed by going to another app and hitting a key or two.
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#singleinstance force
Menu, Tray, Icon, Shell32.dll, 177    ; An arrow icon (seemed somewhat suitable)
Menu, Tray, Tip, 
(
Ctrl-Win-JLUYHNEI (QWERTY YUIOHJKL)
navigate like colemak.vim

unei(UNEI) - arrows(x5)
lyLY - WORDs
jhJH - PgUp/PgDn/Home/End
)

;    Note: I use scan codes to make it more layout independent (if for some reason you're not using Colemak).
;    Check that these codes are right for you, or just use letters instead (e.g., ^!u::).
^#SC017:: Send {Up}         ; Colemak 'u' (QWERTY 'i')
^#SC024:: Send {Left}       ; Colemak 'n' (QWERTY 'j')
^#SC025:: Send {Down}       ; Colemak 'e' (QWERTY 'k')
^#SC026:: Send {Right}      ; Colemak 'i' (QWERTY 'l')
^#+SC017::Send {Up 5}       ; Colemak 'U' (QWERTY 'I')
^#+SC024::Send {Left 5}     ; Colemak 'N' (QWERTY 'J')
^#+SC025::Send {Down 5}     ; Colemak 'E' (QWERTY 'K')
^#+SC026::Send {Right 5}    ; Colemak 'I' (QWERTY 'L')
^#!SC017::Send {Esc}        ; Colemak 'u' (QWERTY 'i')
^#!SC024::Send !{Left}      ; Colemak 'n' (QWERTY 'j')
^#!SC025::Send !{Home}      ; Colemak 'e' (QWERTY 'k')
^#!SC026::Send !{Right}     ; Colemak 'i' (QWERTY 'l')

^#SC016:: Send ^{Left}      ; Colemak 'l' (QWERTY 'u')
^#SC018:: Send ^{Right}     ; Colemak 'y' (QWERTY 'o')
^#+SC016::Send ^+{Left}     ; Colemak 'L' (QWERTY 'U')
^#+SC018::Send ^+{Right}    ; Colemak 'Y' (QWERTY 'O')
^#!SC016::Send {F5}         ; Colemak 'l' (QWERTY 'u')
^#!SC018::Send {F11}        ; Colemak 'y' (QWERTY 'o')

^#SC015:: Send {PgUp}       ; Colemak 'j' (QWERTY 'y')
^#SC023:: Send {PgDn}       ; Colemak 'h' (QWERTY 'h')
^#+SC015::Send {Home}       ; Colemak 'J' (QWERTY 'Y')
^#+SC023::Send {End}        ; Colemak 'H' (QWERTY 'H')
;^#+SC016::Send {Home}       ; Colemak 'L' (QWERTY 'U')
;^#+SC018::Send {End}        ; Colemak 'Y' (QWERTY 'O')

[edit: I'm thinking whether this could be done using only the Win key, a la that old "half-colemak" script. I'll look into it. The way I see it, it ought to be possible to use a script that gives you both the half-keyboard, NumPad and the nav keys - all accessible by using different "extend keys". That's a fascinating thought. My thoughts on the NumPad moved into the char block are in this thread: https://forum.colemak.com/viewtopic.php?id=364 and there's a further topic on punctuation for programmers in the thread https://forum.colemak.com/viewtopic.php?id=387 - all these should be doable apart from the currency and special symbols since I'm now talking about remapping key scan codes rather than mapping symbols to keys. An interesting facet of all this is that the chording principle meets the modal principle; one may hope that something good comes of it.]

Last edited by DreymaR (26-Aug-2008 23:42:13)

*** 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: 31-Aug-2006
  • Posts: 7

I've been using Emacs, but now I'm back to Vim :)

colemak.vim has improved a lot since last time. A suggestion:

vnoremap r i|

This way you can also use e.g. rp in visual mode to select a paragraph. The current behavior of r in visual mode is replace character under cursor.

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

Lately, I've been working a bit on help screens. In the process, I uncovered a lot of seemingly unfinished mappings. Some of these may be left as duplicates to aid the transition, but at the same time there are things that have gone missing and I think many users would like to see most of them back! Often, you don't use a certain function but it's important to someone else - and once you have a closer look at things you'll want to use it too! Not sure what to think of the s(ubstitute) for instance. And I don't really accept losing good moves to the arrow keys since those are way off to the side of the home position and that's where I want to stay!

At any rate, here's one thing I've come up with this far:  A colemak.vim helpscreen that you can keep in a pane at the top (or wherever you like) while you're vimming! It feels useful to me. I'm still uncertain about some things in it though, so please comment and enlighten!

"+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
"|          |          |          |          |          |          |          |          |          |          |          |          |          |
"|~ Case    |! ExtFlt> |@ PlyMcr· |#  <-=    |$  ->|    |% GoMatch |^  <--    |& Rep :s  |*  =->    |( <-Jump  |) Jump->  |_ LastLin |+ LineUp? |
"|` Go Mk·  |1         |2         |3         |4         |5         |6         |7         |8         |9         |0  |<-    |- TopLine |= Format> |
"+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
"|  NextTab |  VisBlk? |  Close?  |  GUIFind |  =<Up>?  |  FileInf |  Bof!    |  <-WORD? |  1/2PgUp |  WORD->? |          |          |          |
"|<TAB>     |Q PlyMcrQ |W Warp->| |F <-Find· |P <-Prch· |G LstLin? |J JoinLn? |L  <--  ? |U  5Up    |Y  ->|  ? |: ExLine? |{ <-Parag |} Parag-> |
"|<ESC>     |  RecMcr· |  Warp >  |  Find·-> |  Prch·-> |  g-Cmd·  |  PgUp    |  <-word  |    Up    |  word->  |; ExLine? |[ <-Misc· |] Misc·-> |
"+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
"           |  AreaAll |  WinCmd? |  Save    |  NewTab  |  DelWord |  Eof!    |   ???    |  1/2PgDn |  =<Tab>? |  GUIOpen |          |          |
"Ctrl+:     |A AreaLin |R RepMode |S |<-Ins  |T Att->|  |D Del->|  |H TopLin? |N 5Left   |E  5Dn    |I 5Right  |O OpenUp  |" SetReg· || GoCol1  |
"Up/Dn scrl |  Area    |  Replce· |  InSert  |  ATtach  |  Delete> |  PgDn    |   Left   |    Dn    |   Right  |  OpenDn  |' GoMk·|< |\ (usr)·? |
"PgUp/Dn HL +----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
"           |  Undo?   |  ClpCtLn |  ClpCpLn |  ClipIns |  VisBlok |          |  <Entr>? |          |          |          |
"           |Z Redo    |X CutLine |C CopyLin |V <-Paste |B RevPpFf |K <-Next§ |M MidScr? |< <-Indnt |> Indnt-> |? <-Find§ |    · = char arg.
"           |  Undo    |  Cut >   |  Copy >  |  Paste-> |  RepPpFf |  Next§-> |  Set Mk· |, (usr)?  |. Repeat  |/ Find§-> |    > = move arg.
"           +----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
"
"Quick colemak.vim helpscreen - DreymaR, 0809                                                                                       [columns=149]
"
"Legend: |<- <-- ->| bol/hol/eol; Mk mark; Flt filter; Mcr macro; Reg register; = same/ident.; § pattern; Warp change; Area visual; 'Pr(oa)ch 'till.
"Notes: Some keys (sXUQK) are now available as g-commands. Ctrl-Shift-Up/Dn swaps lines. Use r(educed) for i(nner). A count may be used with - _ G |.
"Uncertainties: What about + H : \ G M J (should've been a move?)
"Missing: Ctrl-D in x (show alternatives), C-T (tag stack), z, eE, sS, -_, Top/Mid/Bottom?, move to sentence </> - old () move)?
"
"Suggestions: L/Y WRDs; C-LY/ly WRD/wrd back and forward (E/e and gE/ge - if possible); JHG Top/Bot/Mid; C-u/e scroll-in-place
"Alternatively: j/h 1/2 PgUp/PgDn (or put the old -/_ on j/h?); C-,/. tag jumps (does mapping of symbols work at all); reclaim C-w; ???
"Problem: Some C-mappings are synonyms that cannot be remapped?! <C-i>=<Tab>;
"
"
" Show the colemak.vim helpscreen in a read-only window split - you could source this at the end of your _vimrc, and navigate with C-r u/e and -/_.
17sview $VIM/cmkscr.vim
wincmd w
"

A few points I'd like to mention:
- Arrow keys aren't good enough substitutes for main block movement keys. They're too far away for scroll-in-place. They're okay for line reordering though!
- Compliance may be taking too much of a hurt. I'd like to have WRDs back in style, on L and Y. It'd also be nice to see the l and y keys as pure word keys, meaning that C-l/y should map to ge/e (and C-L/Y to gE/E; if that doesn't work yet we'll live with a gl/gy for now).
- Gotta have the z commands! Either on , or \ (maybe the comma key, keeping the backslash for custom mapping as is the default?). Or the best might be the colon, if you use semicolon for ex cmds?!
- Special Shai functionality could utilize more Ctrl-mappings? Much of the default Ctrl-mapping is only half intuitive and/or a shambles. So, C-u/e for scroll-in-place sits naturally on the u/e (up/dn) keys - and C-n/i could be the duplicate mappings for $/^. (I ran into a problem there though: Some keys seem to be synonyms to other keys, and I cannot unmap the C-i turning into a <Tab>!) The PgUp/PgDn functions should also be on the same keys so I suggest taking C-j/h for the 1/2-pages (which are the most useful in my opinion). Probably, I'll want to keep the Bof/Eof there and just use 1/2-page on j/h; full PgUp/PgDns are only twice as many of those.
- I'm guessing that some users will complain if the Top/Mid/Bot keys are messed up or lost, so JGH is my choice. I really think the J shouldn't be Join since the J key is so busy being in the movement block now. M(erge) should be okay.
- The + key could inherit the old _ function?
- C-; for Ex Mode (in addition to gQ)? (Is there a problem remapping symbols though?) Maybe just g; instead.
- As far as I can see, the important sentence move is lost! I suggest bringing it back to where it was on () and putting the special Jump functions elsewhere. C-,/. is one option. For some reason, I don't believe C-mappings of the number keys is nice; it's bound to collide with something else I fear.
- I'd use C-Q instead of C-W for closing. That way, the windows key won't have to move and compliance will be much higher.
- C-R should then do something else. Maybe... GUI open? For old Dvorak users it'd ring a bell, hehe. I think C-O is supposed to do a few other things that it cannot do now.

Again - what exactly is the problem with C-S-mappings? They work on the line reordering because that's on non-letter keys only, is that so? I suppose you've tried both, e.g., C-Y and C-S-y before giving up on them. A shame if they cannot be used, but maybe in a later Vim patch?

[edited a bit - in case someone wondered]

Last edited by DreymaR (17-Oct-2008 16:23:43)

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

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

Update: I tried autoloading the help screen but that caused a load dialogue so I had to hit Enter; also, it got annoying to get the helpscreen up on every Vim window every single time. Instead I'm now using an abbreviation, so that when I type ':ars' and hit Enter the helpscreen loads in a new window pane. I think that's nifty.

I'll just post my vimrc file here; maybe someone can have a look at it and give me a tip or two?  :)

" Personal Vim _vimrc settings for Øystein Bech "DreymaR" Gadmar
" To use, put this file into Vim/GVim's top dir ($VIM)
"-------------------------------------------------------------------------------

" Various settings, some non-default in colemak.vim and some others
set noinsertmode        " we want to start in normal mode unlike, e.g., cream
set noswapfile            " don't make a .swp file (especially when running portably)
"set backup            " do keep a '~' backup file though
set nobackup            " don't keep a '~' backup file (especially when running portably)
set lazyredraw            " don't redraw screen during macros and other non-typed commands
set ignorecase            " ignore case in patterns...
set smartcase            " ...except for mixed or upper case
set autoindent            " Enter opens new lines at the same indent level
set ruler            " show the cursor position all the time
set incsearch            " Display the match for a search pattern when halfway typing it
set backspace=indent,eol,start    " Allow backspacing over autoindents, linebreaks and insert start

if has("gui_running")
    source $VIMRUNTIME/mswin.vim
"    behave mswin        " make the mouse behave like a Windows mouse (not xterm) - included in mswin.vim
    set guifont=lucida_console:h09
    "colorscheme evening
    colorscheme darkblue
    "colorscheme ron
    highlight Normal guibg=#001122
    "highlight LineNr ctermfg=darkcyan guifg=darkcyan
    "highlight Comment ctermfg=green guifg=#66ff00
    "highlight Statement ctermfg=yellow gui=bold guifg=#ffcc33
    winpos 30 0
    set lines=56        " Fits an 1152x864 screen resolution
    set columns=157
    set showcmd        " Display an incomplete command in the lower right corner of the Vim window
    set number        " display line numbers
    set hlsearch        " highlight search patterns
    set showtabline=2    " always show tab page labels
endif

"-------------------------------------------------------------------------------

mapc    " Clear all old mappings, if any
"if has("gui_running") | source $VIMRUNTIME/mswin.vim | endif    " mswin is run above already

" This one isn't working! Not done in mswin but in the source somewhere, <Tab> and <Ctrl-I> become synonyms...
" It seems to be because CTRL-I is a synonym to <Tab> in the Jump command, which is "hardcoded"?
"unmap <C-i>

"-------------------------------------------------------------------------------

source $VIM/colemak.vim        " Use this line if colemak.vim is in Vim's top dir ($VIM)
"source $VIM/../../Data/settings/colemak.vim    " Use this line for GVimPortable

" Show the colemak.vim helpscreen in a read-only window split
" You could insert this in your _vimrc, and navigate with C-r u/e and -/_.
"if winnr($) > 1 | wincmd o | endif
"17sview $VIM/cmkscr.vim
":wincmd w

" To get the Colemak help screen, type :ars and hit Enter - to close it (and other windows...) use :sra
cnoreabbr <expr> ars (getcmdtype() . getcmdline() != ':ars' ? 'ars' : 'source $VIM/cmkscr.vim')
cnoreabbr <expr> sra (getcmdtype() . getcmdline() != ':sra' ? 'sra' : 'wincmd o')

"-------------------------------------------------------------------------------

" Unresolved mappings in colemak.vim (per 080421):

" End of word forwards/backwards
"nnoremap ; e|xnoremap ; e|onoremap ; e|
"nnoremap g; ge|xnoremap g; ge|onoremap g; ge|
nnoremap gy e|xnoremap gy e|onoremap gy e|
nnoremap gl ge|xnoremap gl ge|onoremap gl ge|
nnoremap gY E|xnoremap gY E|onoremap gY E|
nnoremap gL gE|xnoremap gL gE|onoremap gL gE|
" I don't want to lose the hol/eol trick, and the C-n/i keys don't work (yet?)!
"nnoremap <C-y> e|xnoremap <C-y> e|onoremap <C-y> e|
"nnoremap <C-l> ge|xnoremap <C-l> ge|onoremap <C-l> ge|

" Window sizes, folds, etc. - the whole range of 'z' commands!
noremap , z|

" Fuller i>r remapping (fun to select inner in v-mode; but a(ll) doesn't work...)
vnoremap r i|

" Substitute
nnoremap gs S|xnoremap gs S|

" Mappings in colemak.vim (per 080421) that I want to change:

" Home/end of line
" If I use C-n, I have to move the Autocomplete function?!
"nnoremap <C-n> ^|xnoremap <C-n> ^|onoremap <C-n> ^|
" Because of the synonym effect, (i)noremap <C-i> messes up <Tab>!
"nnoremap <C-i> $|xnoremap <C-i> $|onoremap <C-i> $|
"inoremap <C-n> <Home>|cnoremap <C-n> <Home>|
"inoremap <C-i> <End>|cnoremap <C-i> <End>|
nnoremap <C-l> ^|xnoremap <C-l> ^|onoremap <C-l> ^|
nnoremap <C-y> $|xnoremap <C-y> $|onoremap <C-y> $|
inoremap <M-L> <Home>|cnoremap <M-L> <Home>|
inoremap <M-Y> <End>|cnoremap <M-Y> <End>|

" 2PageUp/2PageDown - may not be enough C-mappings for this (we want Eof/Bof!)
"nnoremap <silent> <expr> <C-j> (winheight(0)*2) . "\<C-u>"
"nnoremap <silent> <expr> <C-h> (winheight(0)*2) . "\<C-d>"
"xnoremap <silent> <expr> <C-j> (winheight(0)*2) . "\<C-u>"
"xnoremap <silent> <expr> <C-h> (winheight(0)*2) . "\<C-d>"
cnoremap <M-j> <PageUp>|
cnoremap <M-h> <PageDown>|

" Half page up/down - this may be the most useful page function?
nnoremap <silent> <expr> j (winheight(0)/2) . "\<C-u>"
nnoremap <silent> <expr> h (winheight(0)/2) . "\<C-d>"
vnoremap <silent> <expr> j (winheight(0)/2) . "\<C-u>"
vnoremap <silent> <expr> h (winheight(0)/2) . "\<C-d>"
inoremap <silent> <expr> <M-j> "\<C-o>" . (winheight(0)/2) . "\<C-u>"
inoremap <silent> <expr> <M-h> "\<C-o>" . (winheight(0)/2) . "\<C-d>"

" WORD left/right is brought back on shift-word keys
noremap L B|
noremap Y W|

" Cursor position jumplist
unmap (
unmap )
nnoremap <C-[> <C-o>|
nnoremap <C-]> <C-i>|
" The following remapping isn't working?!
"nnoremap <C-,> <C-o>|
"nnoremap <C-.> <C-i>|

" No longer map ; to : as I'm using a layout with unshifted colon.
nunmap ;|xunmap ;|

"Might as well bring Ex mode back in style from the exile over at Q.
noremap g: Q|

" Open new commands in a new Tab - but we also want the old way accessible!
"cnoreabbr <expr> h  (getcmdtype() . getcmdline() != ':h'  ? 'h'  : 'help')
cnoreabbr <expr> he (getcmdtype() . getcmdline() != ':he' ? 'he' : 'help')
"cnoreabbr <expr> e  (getcmdtype() . getcmdline() != ':e'  ? 'e'  : 'edit' )
cnoreabbr <expr> ed (getcmdtype() . getcmdline() != ':ed' ? 'ed' : 'edit' )

" (GUI) Start/end of document
"nnoremap <C--> gg0|xnoremap <C--> gg0|snoremap <C--> <C-Home><Home>|
"nnoremap <C-_> G$|xnoremap <C-_> G$|snoremap <C-_> <C-End><End>|

" (GUI) Move cursor to top/bottom/middle of screen
nnoremap J H|vnoremap J H|inoremap <M-J> <C-o>H|
nnoremap H L|vnoremap H L|inoremap <M-H> <C-o>L|
nnoremap G M|vnoremap G M|inoremap <M-G> <C-o>M|

" Join/Merge lines
nnoremap M J|vnoremap M J|inoremap <M-M> <C-o>J|

" (GUI) Scroll in place
nnoremap <C-u> <C-y>|inoremap <C-u> <C-o><C-y>|
nnoremap <C-e> <C-e>|inoremap <C-e> <C-o><C-e>|

" (GUI) Tabs need to work in ic modes too?
" Not sure whether this is working as intended!!!
noremap <silent> <C-S-Tab> :<C-u>tabprev<CR>|inoremap <silent> <C-o><C-S-Tab> :<C-u>tabprev<CR>|cnoremap <silent> <C-o><C-S-Tab> :<C-u>tabprev<CR>|
noremap <silent> <C-Tab> :<C-u>tabnext<CR>|inoremap <silent> <C-o><C-Tab> :<C-u>tabnext<CR>|cnoremap <silent> <C-o><C-Tab> :<C-u>tabnext<CR>|

" Get back the <C-d> functionality for the command line (no Delete)?
cunmap <C-d>

" New/close/save is <C-Q> (no more needed for Visual Block mode!)
noremap <silent> <C-q> :<C-u>call CloseWindow()<CR>|
inoremap <silent> <C-q> <C-o>:<C-u>call CloseWindow()<CR>|cnoremap <silent> <C-q> <C-c>:<C-u>call CloseWindow()<CR>|

" Window handling: <C-w> is now no longer <C-r>! We won't have to remap more than necessary this way.
unmap <C-w>
unmap! <C-w>
unmap <C-r>
" <C-r><C-r> - open a new window
unmap <C-r><C-r>
unmap <C-r>n
unmap <C-r>u
unmap <C-r>e
unmap <C-r>i
" <C-w><C-t> opens a new window - analoguous to the Tabs
nnoremap <C-w><C-t> <C-w>n|xnoremap <C-w><C-t> <C-w>n|
nnoremap <C-w>n <C-w>h|xnoremap <C-w>n <C-w>h| 
nnoremap <C-w>u <C-w>k|xnoremap <C-w>u <C-w>k| 
nnoremap <C-w>e <C-w>j|xnoremap <C-w>e <C-w>j| 
nnoremap <C-w>i <C-w>l|xnoremap <C-w>i <C-w>l| 

" Todo: C-p/C-i/C-m/C-n???
"+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
"|          |          |          |          |          |          |          |          |          |          |          |          |          |
"|~ Case    |! ExtFlt> |@ PlyMcr· |#  <-=    |$  ->|    |% GoMatch |^  <--    |& Rep :s  |*  =->    |( |<-Sent |) Sent->| |_ LastLin |+ NextLin |
"|` Go Mk·  |1         |2         |3         |4         |5         |6         |7         |8         |9         |0  |<-    |- TopLine |= Format> |
"+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
"|  NextTab |  Close   |  WinCmd  |  GUIFind |  =<Up>?  |  FileInf |  Bof!    |   <--    |    ?     |   ->|    |          |  <-Jump  |  Jump->  |
"|<TAB>     |Q PlyMcrQ |W Warp->| |F <-Find· |P <-Prch· |G ScrMid  |J ScrTop  |L <-WORD  |U  5Up    |Y WORD->  |; z-Cmd·  |{ |<-Para |} Para->| |
"|<ESC>     |  RecMcr· |  Warp >  |  Find·-> |  Prch·-> |  g-Cmd·  |  1/2PgUp |  <-word  |    Up    |  word->  |: ExLine  |[ <-Misc· |] Misc·-> |
"+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
"           |  AreaAll |  Redo?   |  Save    |  NewTab  |  DelWord |  Eof!    |  =<Dn>?  |  1/2PgDn |  =<Tab>? |  GUIOpen |          |          |
"Ctrl+:     |A AreaLin |R RepMode |S |<-Ins  |T Att->|  |D Del->|  |H ScrBot  |N 5Left   |E  5Dn    |I 5Right  |O OpenUp  |" SetReg· || GoCol1  |
"Up/Dn scrl |  Area    |  Replce· |  InSert  |  ATtach  |  Delete> |  1/2PgDn |   Left   |    Dn    |   Right  |  OpenDn  |' GoMk·|< |\ (usr)·  |
"PgUp/Dn HL +----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
"           |  Undo?   |  ClpCtLn |  ClpCpLn |  ClipIns |  VisBlok |  Digraph |  <Entr>? |          |          |          |
"           |Z Redo    |X CutLine |C CopyLin |V <-Paste |B RevPpFf |K <-Next§ |M MidScr? |< <-Indnt |> Indnt-> |? <-Find§ |    · = char arg.
"           |  Undo    |  Cut >   |  Copy >  |  Paste-> |  RepPpFf |  Next§-> |  Set Mk· |, (usr)·  |. Repeat  |/ Find§-> |    > = move arg.
"           +----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
"
"Quick colemak.vim helpscreen - DreymaR, 0809                                                                                       [columns=149]
"
"Legend: |<- <-- ->| bol/hol/eol; Mk mark; Flt filter; Mcr macro; Reg register; = same/ident.; § pattern; Warp change; Area visual; 'Pr(oa)ch 'till.
"NB: Please understand that this sheet cannot possibly cover everything. It's pretty much mode naïve and modes are everything, for instance.
"    Luckily, one idea in colemak.vim is to make functionality more consistent over multiple modes (although you may have to use Meta/Alt!).
"Notes: Some keys (sXUQK) are now available as g-commands. Ctrl-Shift-Up/Dn swaps lines. Use r(educed) for i(nner). A count may be used with - _ G |.
"Changes: M JHG jh ; LY C-ly , C-[] C-q C-w () C-ue abbreviations (he ed ars). These are changed relative to colemak.vim (per 080421).
"
"
"Missing: Ctrl-D in x (show alternatives)?, C-T (tag stack)?, eE, sS, -_,
"Problem: Some C-mappings are "hard-coded" synonyms that cannot be remapped?! <C-i>=<Tab> (can be handy?); <C-m>=<Enter> etc.?
"
" Show the colemak.vim helpscreen in a read-only window split. You could source this from your _vimrc, and navigate with, e.g., C-w u/e and -/_.
17sview $VIM/cmkscr.vim
wincmd w
"

Note that when the helpscreen is in a 17-line window only the keyboard "image" shows, but if you C-w w (window change) into it and for instance go to EOF (using C-H!) you'll see only the legend/comments part instead.

Last edited by DreymaR (17-Oct-2008 16:26:00)

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

Offline
  • 0
  • Reputation: 0
  • From: Ann Arbor, MI
  • Registered: 25-Sep-2008
  • Posts: 36

Shai, regular Vim will let you move up and down by a line of wrapped text using the gj and gk keys.  Is it possible to edit colemak.vim to work the same way with the "u" and "e" keys?  Currently, they are scattered around the keyboard because they are set to use the j and k keys.

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

jrick:

nnoremap gu gj, nnoremap ge gk.

Offline
  • 0
  • Reputation: 0
  • From: Ann Arbor, MI
  • Registered: 25-Sep-2008
  • Posts: 36
tomlu said:

jrick:

nnoremap gu gj, nnoremap ge gk.

Thanks!

Still, it would be nice if it was part of colemak.vim.

EDIT: btw, it's nnoremap ge gj, nnoremap gu gk ;)

Last edited by jrick (12-Nov-2008 21:56:10)
Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

I'm working (slowly!) on a more light-handed implementation of colemak.vim for myself. I keep taking back more and more changes that I've found not to be absolutely necessary, because I feel that Vim is so stuffed with functionality that you can hardly swing a hotkey in there without bumping into something. I've already thought of gj/gk, and gh/gH for instance. Once I have a somewhat finished result, I'll post it.

I'm wondering about the standard noremap; this remaps the n, v and o modes. Shai often uses n and x (non-Select Visual/Area mode) explicitly (I think he's missing the o mode mappings in some places!). If I use noremap where he uses nnoremap and xnoremap, will I then break the Select mode?

One solution I've found to the functionality crowding is to lean more heavily on the Alt/Meta mappings! These aren't normally used because the GUI menu system uses them. However, in Windows at least you can press and release the Alt key, and then press the menu shortcut key! This produces the same result as pressing them both together, but frees up a whole new set of hotkeys. On my keyboard at least, the left thumb can easily reach the Alt key so such combinations are easily executed. Since we've already started using Alt/Meta mappings for ic mode navigation, it's only a step further to make a few more. I hope this'll work for others too.

*** 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

Dreymar: In my experience you can pretty much trample the alt bindings of any program with little loss in functionality. Go nuts.

Personally, I wouldn't remap any commonly used function of Vim's into a chorded combination. There's another program that chords left and right and that I don't use for that reason - Emacs...

I am a heavy Vim user now, and I've managed to remap pretty much all of the keyboard without losing any vital functionality, so it is possible.

Offline
  • 0
  • Reputation: 0
  • Registered: 18-Mar-2008
  • Posts: 19

My problem is that some motifs, like j for down are repeated in many commands, like j, gj, and others that I don't remember, and one has to remap each and every one of these commands to n, gn, etc..
Is there a way around this?

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

Nathan: Not that I know of. I'm remapping j, J, gj, gJ etc separately.

Tomlu: Care to post your remap/vimrc file(s), if you feel you have any smart tricks in there?

I think that Vim uses a bit too little chording, just as Emacs apparently uses way too much chording. I'm growing fond of <M-r> for <Esc>, since it allows me to stay on the home row for instance. Shai's <Tab> remappings became too annoying for me so I used <M-t> instead which seems to be working well - and also doesn't require any stretches from the home row. Things like that.

In line with the PKL/"Extend" topics, I'm happy with the UNEI/LY/JH nav key block (maybe with :O[' added for further functionality - I'm thinking Esc/BS/Ins/Del) and will be using those not only in Vim but as Windows "extend" mappings (I prefer to call them "transpositions" though). It all comes together, which is nice. Since in Windows you use the Shift-arrows to select, I think I'll map shift-UNEI to select-mode movement in Vim too. I may move Shai's fun "turbo" mode to Meta key mappings exclusively then.

*** 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

A couple of comments:

The #ifvim directives are there because I use the same source for ViEmu and gvim, and ViEmu doesn't support a lot of things.

The mappings should be very similar to Shai's. In terms of useful tricks that I haven't seen everyone-and-their-vim-using-dog doing, I don't think there's much, but I'd direct your attention to my nifty folding method (in Python) that folds:

def python_function(foo, bar):
   """ Some docstring for the function """
   ...code

into

+   def python_function(foo, bar): Some docstring for the function

I also remap f to t in operator pending mode like so: onoremap f t. Highly useful.

set ignorecase
set smartcase
set gdefault
set hlsearch        " highlight search patterns
set incsearch        " enable incremental search

#ifvim
set nocompatible    " make Vim behave in a more useful way
set hidden              " Allow hiding of non-saved buffers
set lazyredraw        " don't redraw screen while executing macros/mappings
set ruler        " show the cursor position all the time
set showcmd        " display incomplete commands
set virtualedit=block    " allow virtual editing in Visual block mode
set backspace=indent,eol,start  " allow backspacing over everything in insert mode

set scrolloff=10        " Number of rows before edge of screen
set nostartofline    " keep cursor in the same column if possible
set whichwrap=b,s,[,],<,>,h,l " allow cursor to wrap between lines
set nowrap

set nobackup
set dir=c:/temp      " Set swap file directory

set shortmess=AatI       " Get rid of 'press ENTER to...' message
set statusline=%<%F%m%r%h%w\ %y\ \ %{strftime(\"%c\",getftime(expand(\"%:p\")))}%=\ line:%04l\/%04L\ col:%3c\ ascii:%3b
set laststatus=2

filetype plugin on
filetype indent on
#endif




"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Keyboard maps
"


" Q
nnoremap q q|       " Record macro
nnoremap Q @q|      " Macros (replay the macro recorded by qq)

" W
nnoremap w "_c|     " Change  
vnoremap w "_c
nnoremap W "_C|     " Change until end of line  
onoremap w iw|      " inner word

" F
nnoremap f f|       " Find next char on line
onoremap f t|       " But delete to instead of to and including

" P
noremap p ;|        " Repeat last f, t
noremap P ,

" G
nnoremap g g|       " Go to

" ----------------------------------------------

" A
nnoremap a V|       " Visual line mode
nnoremap A v|       " Visual mode

" R
nnoremap r r|       " Replace

" S
nnoremap s i|       " Insert mode
nnoremap S I|       " Insert at beginning of line
vnoremap s I|       " Block insert

" T
nnoremap t a|       " Append
nnoremap T A|       " Append to end of line
vnoremap t A|       " Block append

" D
nnoremap d d|       " Delete

" ----------------------------------------------

" Z
nnoremap z u|       " Undo
nnoremap Z <C-r>|   " Redo   
nnoremap <C-z> u

" X
nnoremap x "_x|     " Delete char into black hole  
vnoremap x "_x
nnoremap <C-x> "*dd|" Cut into clipboard       

" C
nnoremap c y|       " Copy
onoremap c y
vnoremap c y
nnoremap C y$
nnoremap <C-c> "*Y| " Copy into clipboard      
cnoremap <C-c> <C-y>

" V
nnoremap v p|       " Paste
nnoremap V P
nnoremap <C-v> "*p| " Paste into clipboard      
inoremap <C-v> <c-r>"
cnoremap <C-v> <C-r>

" B
#ifvim
nnoremap b %|       " Match brace
onoremap b %
#endif


" ----------------------------------------------
" ----------------------------------------------

" J
#ifvim
nnoremap j :call SwapParams("forwards")<cr>
#endif

" L
noremap l b|       " Word left 
noremap L zk
nnoremap + zr|     " Open more folds

" U
nnoremap u k|       " Up 
vnoremap u k
nnoremap U 5k|      " 5*Up   
vnoremap U 5k

" Y
noremap y w|       " Word right 
noremap Y zj

" ----------------------------------------------

" H
nnoremap h za|     " Toggle fold
nnoremap H zR|     " Turn off all folds
nnoremap <c-h> zt  " Scroll cursor to top (minus scrolloff)

" N
nnoremap n h|      " Left  
vnoremap n h
noremap N ^|       " Start of line 
inoremap <C-n> <C-p>| " Word completion

" E
nnoremap e j|      " Down  
vnoremap e j
nnoremap E 5j|     " 5*Down   
vnoremap E 5j 
" map ( prev-function

" I
nnoremap i l|      " Right  
vnoremap i l
noremap I $|       " End of line 
" map ) next-function

" Indentation text motion
#ifvim
omap ii iB
omap ai aB
#endif

" O
nnoremap o o|      " Open new line  

" '

" ----------------------------------------------

" K
nnoremap k n|      " Search next  
nnoremap K N|      " Search prev  

" M
nnoremap m /|      " Search
nnoremap M ?|      " Search backward  
nnoremap - zm|     " Close more folds

" ,
#ifvim
let mapleader = ","
let g:mapleader = ","
#endif

" .
nnoremap . .|      " Repeat command  

" ----------------------------------------------
" ----------------------------------------------

" Backspace
inoremap <C-BS> <C-w>|  " Insert mode delete word backwards

" Space
nnoremap <space> 10j|       " Page down
nnoremap <s-space> 10k|     " Page up

" Esc
nnoremap <Esc> <Esc>:nohlsearch<bar>pclose<CR>

" Return
nnoremap <CR> i<CR><Esc>



"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Indentation
"
#ifvim
set tabstop=4           " Tabs size
set shiftwidth=4
set softtabstop=4       " To make backspace erase tabs
set expandtab
set smartindent

function! Sub(word, sub)
    execute '%s/\<' . a:word . '\>/' . a:sub
endfunction

#endif

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Leader commands
"
#ifvim

" Save file
nnoremap <leader>s :w<CR>
" Quit
nnoremap <leader>q :q<CR>

#endif




"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Python
"
#ifvim
#endif



"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Plugins
"
#ifvim

" MiniBufExplorer
let g:miniBufExplModSelTarget = 1
let g:miniBufExplorerMoreThanOne = 0
let g:miniBufExplModSelTarget = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplVSplit = 25
let g:miniBufExplSplitBelow=1

" FuzzyFileFinder
nnoremap <leader>t :FuzzyFinderRemoveCache<CR>:FuzzyFinderFile <C-r>=expand('%:p:h').'\'<CR><CR>
nnoremap <leader>d :FuzzyFinderBuffer<CR>
let g:FuzzyFinderOptions.Base.key_open = '<CR>'
let g:FuzzyFinderOptions.Base.key_open_split = '<C-s>'
let g:FuzzyFinderOptions.Base.key_open_vsplit = '<C-v>'
let g:FuzzyFinderOptions.Base.key_open_tab = '<C-t>'
let g:FuzzyFinderOptions.Base.key_ignore_case = '<C-c>'

#endif

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Buffer/window/tab management
"
#ifvim

" Window management
nnoremap <c-n> <c-w>W|             " Window prev
nnoremap <c-i> <c-w>w|             " Window next
nnoremap <leader>wv <c-w><c-v>|    " Window split vertical
nnoremap <leader>ws <c-w><c-s>|    " Window split horizontal
nnoremap <leader>wn <c-w><c-h>|    " Window left
nnoremap <leader>wi <c-w><c-l>|    " Window right
nnoremap <leader>wu <c-w><c-j>|    " Window up
nnoremap <leader>we <c-w><c-k>|    " Window down
nnoremap <leader>wo <c-w><c-o>|    " Make only window
nnoremap <leader>wd <c-w><c-c>|    " Close window
nnoremap <leader>wf <c-w><c-f>|    " Edit file under cursor in new window

" Tab management
"nnoremap <leader>tn :tabp<CR>|     " Prev tab
"nnoremap <leader>ti :tabn<CR>|     " Next tab
"nnoremap <leader>tw :tabclose<CR>| " Close tab

" Buffer management
nnoremap <leader>bd :Bclose<CR>|   " Close buffer

" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()

function! <SID>BufcloseCloseIt()
   let l:currentBufNum = bufnr("%")
   let l:alternateBufNum = bufnr("#")

   if buflisted(l:alternateBufNum)
     buffer #
   else
     bnext
   endif

   if bufnr("%") == l:currentBufNum
     new
   endif

   if buflisted(l:currentBufNum)
     execute("bdelete! ".l:currentBufNum)
   endif
endfunction

#endif


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Appearance
"
#ifvim
set gfn=Consolas:h10:cANSI
set antialias
set lines=9999 columns=9999
set background=dark
set guioptions-=T
set guioptions-=m
colors peaksea


"
"  Folding appearance
"

python << EOF
import re
import vim

def compile_regexp():
    l = []
    l.append(r'"""(?P<id>.*)"""')        # python_docstring
    l.append(r'"""(?P<id>.*)')           # python_docstring
    l.append(r'#(?P<id>.*)')             # python_comment
    l.append(r'/\*+!?(?P<id>.*?)!?\*+/') # c_singleline_comment, doxygen support
    l.append(r'/\*+!?(?P<id>.*)')        # c_multiline_comment, doxygen support
    l.append(r'//+!?(?P<id>.*)')         # cpp_comment, doxygen support
    l = [r'\s*' + c for c in l]

    global regexp_list
    regexp_list = [re.compile(regexp) for regexp in l]


def match_line(firstline):
    for regexp in regexp_list:
        match = re.match(regexp, firstline)
        if match is not None:
            if match.group('id') is not None:
                return match.group('id').strip()
    return ''

def get_indent_level(line, tabspaces):
    indent = 0
    for c in line:
        if c == ' ': indent += 1
        elif c == '\t': indent += tabspaces
        else: break
    return indent

def indent(line, level):
    return line.rjust(len(line) + level)

def get_fold_str(ibegin, iend):
    ibegin -= 1     # Make sane range
    ret =  ''.join([str(iend - ibegin), ' lines: ',
                    match_line(vim.current.buffer[ibegin]), ' '
                   ])
    ret = ret.replace('"', r'\"')

    tabspace = 4
    level = get_indent_level(vim.current.buffer[ibegin-1], tabspace)
    ret = '+' + indent(ret, level + tabspace - 1)
    return ret

def get_fold_str(ibegin, iend):
    ibegin -= 1     # Make sane range
    line = vim.current.buffer[ibegin]
    ret = '%s {%d lines} %s' % (line.strip(), iend - ibegin, 
                                match_line(vim.current.buffer[ibegin+1]))

    tabspace = 4
    level = get_indent_level(line, tabspace)
    prefix = '+'
    ret = prefix + indent(ret, level - len(prefix))
    return ret

compile_regexp()
EOF

set foldlevel=1
set fillchars="fold: "          " No fill character
set foldtext=FoldText()
set foldcolumn=0
function FoldText()
python << EOF
istart = int(vim.eval('v:foldstart'))
iend = int(vim.eval('v:foldend'))
vim.command('return ' + '"' + get_fold_str(istart, iend) + '"')
EOF
endfunction

#endif
Offline
  • 0
  • Reputation: 0
  • Registered: 28-Nov-2008
  • Posts: 6

I very much appreciate the work you're doing Shai, I think you are the new messiah to end all editor/keyboard-layout wars ;)

Instead of using <space> in normal mode to just insert one space, this code at the end of colemak.vim will make double tapping space do that, but pressing <space> <character> insert that one character.

nmap <space> s_<Esc>r

Also, can you still join lines in Colemak.vim?
And I think the incrementing integer thing (use to be <C-a> and <C-x>) is broken too.

Shai please continue responding to this thread if you have the time, thank you.

Last edited by Jack (02-Jul-2009 02:20:43)
Offline
  • 0