VIM compatibilty mode

665 views
Skip to first unread message

Ali Shah

unread,
Dec 27, 2010, 12:20:44 AM12/27/10
to scintilla-interest
Hi community,
I have been reading into the scintilla code a bit with the purpose of
implementing a basic subset of VIM commands. You can think of it as a
sort of "VIM compatibility" mode so that die hard VIM enthusiasts can
still use IDEs based on scintilla with out sacrificing VIMs text
editing shortcuts. This extension would have the ability to be turned
on and off, ofcource, from the containing program much like how
MonoDevelop allows users to toggle its VIM compatibility mode from a
settings dialog.

I would like to stress that this would not be an attempt to fully
replicate the functionality of VIM, it is purely a subset of commands
that I think would likely be most useful to the average VIM user.

In writing this post, I was hoping to elicit comments on this idea.
Namely if such kinds of patches would be interesting to the project
and if so, any potential pitfalls or development process the
developors would like to see.
Cheers and thanks for scintilla :)
Ali

Neil Hodgson

unread,
Dec 28, 2010, 5:32:30 PM12/28/10
to scintilla...@googlegroups.com
Ali Shah:

> I have been reading into the scintilla code a bit with the purpose of
> implementing a basic subset of VIM commands. You can think of it as a
> sort of "VIM compatibility" mode so that die hard VIM enthusiasts can
> still use IDEs based on scintilla with out sacrificing VIMs text
> editing shortcuts.

Only a very small subset of VIM could be embedded in Scintilla as a
change only to key handling. Even for simple searching, VIM needs a
visible command line and status display.

A command line then introduces a set of policy decisions like:
Where does it go? Does it auto-resize for long commands? How is it
styled? This would expand the scope of Scintilla significantly so I
see it as not belonging inside Scintilla.

The functionality could be implemented in the application but that
would limit its reuse. Perhaps you could implement a composite widget
that contained Scintilla functionality along with a command line.

Neil

Ali Shah

unread,
Dec 31, 2010, 9:49:09 PM12/31/10
to scintilla...@googlegroups.com
Neil,
Thank you for your comments.
Were I to write such a composite widget would you consider adding it
to the scintilla code base? You seem to indicate not, but I thought I
would ask just as well.
Best,
Ali

> --
> You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
> To post to this group, send email to scintilla...@googlegroups.com.
> To unsubscribe from this group, send email to scintilla-inter...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/scintilla-interest?hl=en.
>
>

Neil Hodgson

unread,
Jan 1, 2011, 7:27:12 AM1/1/11
to scintilla...@googlegroups.com
Ali Shah:

> Were I to write such a composite widget would you consider adding it
> to the scintilla code base?

It is unlikely - I wouldn't want to be responsible for its maintenance.

Neil

Eric Promislow

unread,
Jan 1, 2011, 9:17:01 PM1/1/11
to scintilla...@googlegroups.com
ActiveState Komodo, which uses Scintilla, supports a large subset of the
VIM keybindings.  You can even see the source (which is in JavaScript)
at http://svn.openkomodo.com/openkomodo/browse/openkomodo/trunk/src/chrome/komodo/content/keybindings

- Eric


  Neil

Ali Shah

unread,
Jan 1, 2011, 11:52:38 PM1/1/11
to scintilla...@googlegroups.com
Eric, this is useful to know, thank you.
I was really hoping to provide some kind of plug-n-play VIM
functionality to all scintilla-based editors IDEs since they are all
really lightweight and a large number of them are cross platform, it
would be nice to give such a large list of editors something alot of
developers find useful.
Ali

Ali Shah

unread,
Jan 5, 2011, 12:21:59 PM1/5/11
to scintilla...@googlegroups.com
Neil,
I've managed to do as you recommended, that is writing a container
widget to include the command line. It looks like however that in
order to intercept keystrokes to the ScintillaGTK widget, I will need
to subclass it, and override the class_init() function. This will also
give me protected access to the Editor class which, I would expect, be
very useful as I image I cannot accomplish everything with just SSM
(scintilla's send message mechanism).

However, I do not have access to this interface in order to write a
derivative class, since ScintillaGTK's interface is defined within the
CXX file. Would it be possible to decouple the interface from the .cpp
file? I can submit patches if you'd like.

Best,
Ali

Neil Hodgson

unread,
Jan 5, 2011, 7:22:08 PM1/5/11
to scintilla...@googlegroups.com
Ali Shah:

> It looks like however that in
> order to intercept keystrokes to the ScintillaGTK widget, I will need
> to subclass it, and override the class_init() function.

I thought you'd be able to hook keyboard input through the GTK+ API
similar to control subclassing on Windows.

> However, I do not have access to this interface in order to write a
> derivative class, since ScintillaGTK's interface is defined within the
> CXX file. Would it be possible to decouple the interface from the .cpp
> file? I can submit patches if you'd like.

Not sure quite what this would entail but moving the ScintillaGTK
class definition into a header is fine. It is likely that the class
definition will change over time.

Neil

Jeff Pohlmeyer

unread,
Jan 6, 2011, 2:00:35 AM1/6/11
to scintilla...@googlegroups.com
On Wed, Jan 5, 2011 at 6:22 PM, Neil Hodgson wrote:

> I thought you'd be able to hook keyboard input through the GTK+ API


I played around with something like this in the GeanyLua plugin, but
my idea at the time was to display the keystrokes in a calltip rather
than creating a full-fledged edit line. It's been a while (several years ago)
but it looks the the trick is something called "gdk_window_add_filter".

Not sure if it would help but you can check out the code here:
http://tinyurl.com/39nd2qj
(See glspi_keygrab() function around line 559.)


Documentation of what it is supposed to do is here:
http://tinyurl.com/25x79lj

- Jeff

Reply all
Reply to author
Forward
0 new messages