Sublime Forum

Dev Build 2096

#1

Dev Build 2096 is out now. There’s a small number of API related changes, and there’s an experiment I’ve been working on over the last few days - Vintage mode.

Vintage mode is vi style key bindings for Sublime Text 2. It’s very much an experiment at the moment: I don’t know if it’ll stay in for the next regular build. I’d like to see if it’s something people find useful first.

Vintage is initially disabled, to enable it you’ll need to remove it from the (new) ignored_packages global setting. If you do that, you’ll be placed into command mode, with vi style commands available to you. As an aside, adding a package to the ignored_packages setting has the same effect as deleting the package itself: feel free to use this to trim away packages you’re not interested in.

If you’re trying out Vintage, there’s a readme file in Packages/Vintage that’s worth perusing. In short, keep in mind that Vintage isn’t exactly like vi in all respects, some of the major differences are:

  • Insert mode is plain Sublime Text 2 editing, with the usual Sublime Text 2 key bindings: vi insert mode key bindings are not emulated.

  • Visual mode is implicit: if there’s a non-empty selection, Vintage operates in visual mode, otherwise not.

  • Ex commands are not implemented, apart from :w and :e, which work via the command palette.

Vintage itself is implemented entirely as a plugin. I’d be extremely happy to receive any patches, some of the things it needs are:

  • More motions. While the core ones are implemented, there are many that aren’t.

  • Proper support for ex commands

  • Plently of other things that I’m sure I’ve missed

There are no doubt many rough edges at the moment, but at this stage it’d be better to hold off on reporting small bugs and differences with vi. I’m keen to know first if Vintage is something people actually find useful or not.

Finally, I may have missed a few things from the change log this time around - just think of them as bonus features. One of them is that key bindings will now load from ‘Default.sublime-keymap’ files, which is handy if you have a package with identical key bindings across platforms.

0 Likes

#2

Very interesting! The only problem for me is that Sublime Text 2 does not seem to repeat commands when I hold down a shortcut. So when I hold down “j” to move down, it will only move down one line, while the original VI will move down continuously until I let the key go.

Still, it is cool to have VI-bindings as a “core”-feature!

0 Likes

#3

Sorry about that… will fix in the next build

0 Likes

#4

Can’t wait to try the Vintage mode!

0 Likes

#5

Does the ignored_packages setting work on the fly? Is a restart necessary? What about packages that create locks on files inside the package dir?

0 Likes

#6

It’s applied on the fly, yeah - internally, it works just as if the files were deleted. Plugins will be unloaded, but unless they clean up after themselves (via defining an unload_handler() function), then all their effects won’t be undone until the next restart.

0 Likes

#7

Are you on Lion? If yes, this os has a… feature that prevent repeat keystrokes.

0 Likes

#8

Can you give a few details on how Command.description() might be used?

0 Likes

#9

I am loving this so much! – Would love to see 0 (zero -> go to beginning of line), :0 (beginning of document) :blush: (end of document)

0 Likes

#10

[quote=“iamntz”]

Are you on Lion? If yes, this os has a… feature that prevent repeat keystrokes.[/quote]

I believe it only does this for characters that have common accents, such as e, a, or n.
Also, if this bugs the crap out of you like it did me: hints.macworld.com/article.php?s … 1122558299

0 Likes

#11

I love the vi feature, I’ve only been using it for a few hours and its helped me in my workflow already. it greatly increases the possibilities for multiple select and macro creation (specifically the f for find since it works on every line of multi-select! before you just had End to line cursor up in different spots on each line…).

0 Likes

#12

http://dl.dropbox.com/u/497583/screenshots/2011-08-03_1922.png

0 Likes

#13

jps, I love the new vi mode, since I do switch between vim, sublime and VS in my day-to-day work
Innovations/features like this are my reason to buy/pay for Sublime.

0 Likes

#14

It’s commonly used on the C++ side to display lists of things in the menus, for example:

class UrlListCommand(sublime_plugin.WindowCommand):
    urls = ...]

    def run(self, index):
        if index < len(urls):
            open_url(index)
    
    def is_visible()
        return index < len(urls)
    
    def description(self, index):
        if index < len(urls):
            return "Open URL: " + urls[index]

You can then create menu items that call this command with various indices, as done for the open_recent_file command in the main menu.

0 Likes

#15

Another otherwise undocumented feature is 2096 is the ability to bind to wildcard characters. If you setup a key binding to “”, then that’ll match any character, and forward the matched character onto the command via the “character” argument. For example:

{ "keys": "r", "<character>"], "command": "replace_character" }

This is used by Vintage to implement, ‘r’, ‘f’, ‘t’, etc.

0 Likes

#16

If you specify an argument called “character” in the binding, then it’ll get overwritten by the actual typed character. Other arguments are unaffected.

Next build will be out today.

0 Likes

#17

For some reason it seems like my User Key Bindings aren’t loading. If I remove the Default (OSX).sublime-keymap file from Packages/User, the console prints:

found 5 files for base name Default.sublime-keymap

If I put it back, it still prints the same thing. If I fill it with mal-formed JSON, it doesn’t give me an error message on save, even though the default Default (OSX).sublime-keymap will give me such an error.
Thougts?
Thanks!

0 Likes

#18

Build 2097 is out now, addressing the issue where platform specific key bindings weren’t read from the user package.

0 Likes

#19

Wow…i love this!!! You have to keep vintage part of sublime :smile: (you might want to make the cursor more visable in visual mode like screencast.com/t/j2Uk1Z5kDrO)

If I could figure out Build on save I would buy sublime today.

0 Likes

#20

[quote=“iamntz”]

Are you on Lion? If yes, this os has a… feature that prevent repeat keystrokes.[/quote]

Thank you. This was indeed the issue. This new Lion function can fortunately be disabled using

defaults write -g ApplePressAndHoldEnabled -bool false

0 Likes