
Actualvim – Sublime Text 3 input mode powered by Vim itself - jkarni
https://github.com/lunixbochs/actualvim
======
lunixbochs
Author here:

This works using Vim's NetBeans control protocol (inside Vim, do `:help
netbeans` to get an overview. Also see the VimSocket class in vim.py) and
minimal help from a simple VT100 emulator I wrote (found in term.py).

Open the command panel (cmd|ctrl+shift+p) and run the "ActualVim: Monitor TTY"
command if you want to see what's going on in the terminal for any open view.

I actually wrote the first Vim emulation mode in Sublime Text a couple years
back (
[https://github.com/lunixbochs/sublimevim](https://github.com/lunixbochs/sublimevim)
) that possibly inspired the other similar plugins. I consistently ran into
enough unsupported motions with both my own and other plugins that I caved and
wrote ActualVim.

~~~
aidos
Really nice work. I'm happy where I am in vim but if I ever decided to move
this looks like the way to go.

OT It's funny how conditioned I am to seeing __Beans and instantly dismissing
it as something I can't be bothered to look into. Silly biased me; it looks
like a really powerful protocol.

~~~
lunixbochs
I have my share of complaints about the NetBeans protocol. It's actually
pretty weird and incomplete, but it's supported by default so I'm using it.

I think it's meant to be used the other way - using Vim as your frontend to
edit code while using NetBeans to manage the project, lint, compile, etc - but
it had enough functionality I was able to _barely_ make it work the other way.

~~~
justinmk
> NetBeans protocol ... I think it's meant to be used the other way - using
> Vim as your frontend to edit code while using NetBeans to manage the project

eclim[1] is probably an excellent reference-implementation of _both_
approaches. Did you look at it, and if so was it useful?

[1] [https://github.com/ervandew/eclim](https://github.com/ervandew/eclim)

~~~
lunixbochs
Isn't eclim primarily to use Vim as the frontend and Eclipse as the backend?
Same idea, slightly different scenario. I used it for linting Java over in
sublimelint.

I developed ActualVim using only a VT100 reference (
[http://bochs.info/text/vt100.txt](http://bochs.info/text/vt100.txt) ) and
`:help netbeans`

~~~
justinmk
The core of eclim is a server that talks to the Eclipse JDK, for which there
are vim, emacs, etc, front-ends.

Eclim also happens to provide an Eclipse plugin that _embeds_ Vim in Eclipse,
using the NetBeans protocol, just as you are embedding Vim in Sublime. The
author of eclim is also very responsive, if you wanted to ask him about
anything.

~~~
lunixbochs
Is he not just embedding a VT100 emulator and using NetBeans socket to copy
the buffer back and forth? The primary focus of NetBeans integration is to
pass basic state forth and not to facilitate a full Vim embed.

~~~
justinmk
To be honest, I don't know. An eclim discussion[1] implies that eclim is using
Vim's NetBeans protocol, and the eclim code that I have read is well-organized
and the project is mature, so when you said you were having issues with the
NetBeans protocol I thought eclim might be a useful reference for you.

[1]
[https://github.com/ervandew/eclim/issues/100](https://github.com/ervandew/eclim/issues/100)

~~~
lunixbochs
Oh, that's awesome. I didn't think of using it like that.

They're using a Vim script to extend the NetBeans protocol and pass arbitrary
messages back with nbkey/keyCommand. I can totally use this. Thanks!

~~~
justinmk
Very interesting. Thanks for relaying that.

------
xutopia
This makes me want to ask... why not just use vim?

~~~
leokun
Because vim is broken. I gave up vim after 7 years because of all the
segfaults, in-extensibility and just horrible code. Some of the files in the
vim code base are over 20,000 lines with hundreds of ifdefs, and littered with
unsafe pointer use. The code is a horrible experience to just look at, pre
1989 C style functions, mixed tabs and spaces everywhere, and the files aren't
even a valid encoding of any kind whatsoever, instead it has this broken mbyte
that will ruin your day if you touch a vim source file in anything but vim.

If you use vim as is you may not notice much, but vim will forever be limited
to responding only to user interaction with no hope of ever getting any kind
of timers, async actions or event loop.

Try making a simple clock for your status line that updates every second. You
can't. And it will never be possible. Because vim is broken.

~~~
TallboyOne
How much of a challenge would it be to rewrite vim properly? Or is that a
crazy idea..

~~~
recuter
Not that crazy. Vim itself is a reboot of Vi, and there were/are other minimal
Vi clones that are very small (couple of KLOCs). You'd be throwing away the
horrible Vimscript, and sadly the community is married to it.

As a result your neat little Vim2 reboot thing will not be nearly as useful
for a long time, so you've lost backwards compatibility for what? Cleaner
internals? Doesn't really benefit the end user much. :)

~~~
lightblade
I really don't care much about backward compatibility with existing plugins.
We're using vim not the plugins anyway. I justed wanted an terminal editor
with vi bindings.

~~~
eyko
As long as it can parse my .vimrc (but then, that's vimscript)

~~~
platz
Is there so much in your .vimrc that it couldn't be written in a new syntax,
without _that_ much effort? We're not talking about supporting an entire
legacy software app here.

------
aeon10
I love vim's keybindings and cant work without them. I really like sublime but
i just cant leave vim's keybindings which makes me so much efficient. Last
time I tried a vim emulator for sublime it didn't go so well. it wasnt as
smooth and limiting. I hope someone perfects the vim+sublime combo because
that would be killer.

~~~
prawks
Ditto, in Visual Studio. I use viEmu a lot, but it has strange behavior
sometimes and missing features.

~~~
city41
It's still the best vi emulator I've found. If you know of better ones, I'd
love to hear about them.

~~~
et1337
Check out VsVim. It's pretty solid.
[http://visualstudiogallery.msdn.microsoft.com/59ca71b3-a4a3-...](http://visualstudiogallery.msdn.microsoft.com/59ca71b3-a4a3-46ca-8fe1-0e90e3f79329)

------
madmax96
Why wouldn't I just use Vim (or better yet, Emacs) in the first place?

~~~
DoggettCK
Multiple selections has been the killer feature for me, which is the only
thing I haven't found a good replacement for in Vim or Emacs.

~~~
dbpatterson
And of course... [https://github.com/magnars/multiple-
cursors.el](https://github.com/magnars/multiple-cursors.el) for emacs folks (I
use it every day...)

------
zombie_hitler
This is like using vim-mode on emacs.

~~~
lunixbochs
Vim-mode on emacs probably uses an internal emulator and doesn't slave a real
Vim instance to do the work.

In that case, you have at least Vintage, Vintageous, and my original project
sublimevim (that was mostly a proof of concept before we had any of this) as
"vim-mode" in Sublime Text.

------
kal00ma
Just installed it on ubuntu using sublime text 3 (installed from sublime-
text_build-3047_amd64.deb). I get into vim mode when creating new files;
however, when opening existing .py files on disk I don't get the vim editor.

~~~
lunixbochs
Can you report this on the issue tracker?
[https://github.com/lunixbochs/actualvim/issues](https://github.com/lunixbochs/actualvim/issues)

Also can you check the console when opening a file to make sure there's no
error?

------
DannoHung
Things I would actually be interested in for Vim: Some sort of type-validation
plugin for languages like C, C++, Scala, Haskell, etc.

There are ways to get around it, but getting the error in the editor window is
very nice for dummies like me.

~~~
L8D
[https://github.com/scrooloose/syntastic](https://github.com/scrooloose/syntastic)

~~~
DannoHung
Huh, do the syntax checkers for those languages actually do type checking too?

~~~
wrl
For C and C++ at least, it uses your compiler, so yes.

~~~
jkarni
For Haskell too, with ghc-mod[1].

[1] [https://github.com/eagletmt/ghcmod-
vim](https://github.com/eagletmt/ghcmod-vim)

