[TxMt] Re: Best way to get Vim command mode in TM2

Hans Stimer hans.stimer at gmail.com
Wed Dec 14 17:57:01 UTC 2011


I'm so glad you asked!

I used TM since the early days of its release however, I found that its
emacs style command key combinations were starting to cramp up my hands.
This isn't really TextMates fault, emacs style bindings have been a Mac OS
standard for years. By "emacs style" I mean using a combination of meta and
normal keys to do things like: move left or right by a word, or select the
words or paragraphs.

Of course, with a Mac you can always use the mouse, but after 26 years of
mousing, my shoulder is shot. Maybe I just need physical therapy to fix my
mouse shoulder, but for coding I found a much simpler solution. Vim normal
mode.

Vim normal mode is what I referred to as "Vim command mode", which is
incorrect, but I was trying to come up with a way of describing it to non
Vim users.

Vim normal mode is when everything you type is interpreted as a command to
the editor. For instance, "cw" indicates that you want to change the word
after the current cursor position. "hjkl" will move the cursor left, down,
up, right respectively. "wwww" would move 4 words to the right, and "4w"
will do the same. Vim insert mode is when the keys you type show up in your
document. When you use Vim you are constantly switching between insert and
command mode. To return from insert mode back to normal mode you hit the
escape key. Most serious Vim users map the escape key to something handier.
I've mapped the caps lock key to escape which keeps my left hand closer to
home position.

For Mac and Windows people this will seem bizarre and awkward beyond
belief. But there are advantages: you rarely have to reach for the mouse,
and for most work, your hands remain in a very relaxed position and you
won't get the soreness that you get from meta key command combinations.
Some Vim users will even claim that they can work much faster than they can
with a traditional mouse style editor. I personally won't make that claim,
but I will claim that I can easily work an 8+ hour day without shoulder or
hand pain with Vim style editing.

Now you are probably wondering why I just don't use Vim and quit bothering
people. Good question.

Vim has many strengths, but it also has problems: extension system is
fragile and a pain to manage, less common tasks require meta keys, and the
GUI sucks. There are of course some alternatives that try and take some of
the better things from Vim and combine it with a modern GUI editor. Vico,
and SublimeText2 are my favorite examples. Vico is more faithful to the Vim
way, but still provides a nice GUI. However, its plugin system is more
difficult to use, and compared to SublimeText 2, it just isn't as advanced.

SublimeText 2 starts as kind of a TM clone even so far as being able to use
some of the files in a TM bundle. However, it has an extension which
optionally can provide a Vim like mode. This is the best hybrid I've seen
so far between modern GUI editors and Vim. For users who like meta key
combinations and the mouse, SublimeText 2 gives that as the default.
However, if you prefer Vim style editing, you can get that but still have
full access to the GUI when you want it. This works beautifully. I
occasionally use the mouse but not often enough to cause shoulder pain, and
having the mouse and GUI is very handy for less common but critical tasks.

However, I'm a long time TM user, and I have even created a small bundle
and modified a number of others, so I would like to have a reason to come
back to TM. I was thinking with TM2 it might be possible to create a bundle
or plugin that extends TM2 to have a Vim normal mode. TM2 looks to have
some nice improvements and I would like to be able to take advantage of it,
but first I would need to be able to create a Vim like mode. If it isn't
possible I'll stick with SublimeText2, but if it is reasonably possible
then I'll take a stab at making the Vim bundle/plugin.

Some people might think that TM2 shouldn't be able to be extended in such a
direction, but one of the key hallmarks of TM's success is that it can be
nearly all things to all people through bundles and plugins. So if there
are some users that want a Vim like bundle/plugin then why not support them?

On Wed, Dec 14, 2011 at 1:14 AM, Justin Catterall <
100621.1 at masonsmusic.co.uk> wrote:

>
> On 14 Dec 2011, at 01:55, Hans Stimer wrote:
>
>  Is there a way to create a Vim like plugin for TM2? Specifically, can a
>> plugin intercept all keystrokes and invoke built-in commands? If reasonably
>> possible, would it be best done as a bundle or plugin?
>>
>
> Surely if you change editor you learn the 'new' way of doing things. If
> Vim was doing it right you wouldn't be moving to TM. What you may be losing
> with the feature you're describing must be out-weighed by the things you
> are gaining - other wise you would still be mainly using Vim?
>
> If TM can't do what you're looking for, how about one of the third party
> apps that insert snippets or run actions based on keystrokes? Something
> like TextExpander (there are others but I don't recall their names, TE
> works for me).
>
> BTW, I'd be interested what it is Vim is doing for you, I've been using
> Vi/Vim for almost twenty years, never as a hard-core user, more on a casual
> basis, and am not familiar with what you describe. I curious in case I ever
> end up on a system where I have to do a lot of work with Vi/Vim.
>
> --
> Justin C, by the sea.
>
>
> ______________________________**_________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/**listinfo/textmate<http://lists.macromates.com/listinfo/textmate>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20111214/25441736/attachment.html>


More information about the textmate mailing list