Vico home blog download feedback

Automatically hard-wrap text

There's a question if Vico can automatically hard-wrap text at a certain column. Vim can do this when the textwidth setting is non-zero.

This setting is not natively supported by Vico, so the natural follow up question was: "But can I script it?".

Read more…

4 comments

Scripting Vico

Vico is scriptable in the Nu language. The Nu webpage describes it as:

Nu is an interpreted object-oriented language. Its syntax comes from Lisp, but Nu is semantically closer to Ruby than Lisp. Nu is implemented in Objective-C and is designed to take full advantange of the Objective-C runtime and the many mature class libraries written in Objective-C. Nu code can fully interoperate with code written in Objective-C; messages can be sent to and from objects with no concern for whether those messages are implemented in Objective-C or Nu.

Since Vico is written almost exclusively in Objective-C, Nu can take advantage of the native classes that make up Vico. The available classes and methods you can call are being documented here. This allows creating rich plugins that integrate seamlessly with Vico and the rest of Mac OS X.

As an example, here's a "Hello World" example using Cocoa:

(let (alert (NSAlert new))
  (alert setMessageText:"Hello, World!")
  (alert beginSheetModalForWindow:((current-window) window)
                    modalDelegate:nil
                   didEndSelector:nil
                      contextInfo:nil))

Paste this into Vico, select it, and issue the :eval command, and you'll get the familiar greeting as a nice Cocoa sheet. If you want to play with this example, check out Apples documentation for NSAlert.

Read more…

3 comments

Macros and key bindings

Vicos key bindings are flexible and can be changed with a little bit of Nu script. In fact, all key bindings are configured in the keys.nu file in the Resources folder inside the application bundle.

There are 7 built-in maps: the normal, insert and visual maps, the operator map for commands that require a motion such as d and c, maps for the explorer and symbol sidebars and the completion map for the completion window.

You can also create named maps that can be included in other maps if they share the same keys. Vico uses this to bind the arrow keys both in normal, visual and insert mode.

To change a key binding, it's easiest to create a macro. A macro is expressed as a string of one or more vi commands. Modifier keys are written inside angle brackets, for example <ctrl-d>, <alt-shift-down> or <cmd-pageup>. Only use the shift modifier for "command" keys, such as <shift-cr>. For regular characters, use the shifted representation, for example <ctrl-D>.

Here are a couple of examples:

Read more…

20 comments