vicoapp / vico

Mac Programmers Text Editor
http://www.vicoapp.com/
657 stars 89 forks source link

Feature Request - Customize your vi-bindings #11

Closed teoljungberg closed 12 years ago

teoljungberg commented 12 years ago

This would be a featurekiller for me atleast

Shadowfiend commented 12 years ago

What exactly do you mean? Key bindings, commands, or what?

teoljungberg commented 12 years ago

The movement keys, i.e noremap H ^ noremap L g_

Basicly to create a .vimrc-like file that lets you create custom keys, commands and whatnot

Shadowfiend commented 12 years ago

Gotcha. You can do this right now, but you have to use Nu:

(let (map (ViMap normalMap))
  (map map:"H" to:"^")
  (map map:"L" to:"g_))

Notably, g_ isn't implemented, so you'll have to implement it. You can also map to Nu expressions:

((ViMap normalMap) map:"g_" toExpression:(do ()
    ; code for what to do on g_
  ))

Lastly, you can map recursively:

((ViMap normalMap) map:"H" to:"^" recursively:t scope:nil)

I can look into exposing these maps via actual map commands, however.

Shadowfiend commented 12 years ago

Actually I think you can define the command(s) yourself using ExMap:

((ExMap defaultMap) define:"map" syntax:"E" as:(do (command)
  (let (partsArray ((command arg) componentsSeparatedByString:" "))
    (if (= (partsArray length) 2)
      (let (partsList (partsArray list))
        ((ViMap normalMap) map:(head partsList) to:(head (tail partsList))))
      (else
        ; throw an exception or something
      ))))

Warning: not tested hehe. But that should more or less do it.

teoljungberg commented 12 years ago

Great thanks! I'll look into that