Labs/Bespin/Tips: Difference between revisions

From MozillaWiki
< Labs‎ | Bespin
Jump to navigation Jump to search
No edit summary
No edit summary
Line 38: Line 38:
* runconfig: This command will load up the config.js and run it
* runconfig: This command will load up the config.js and run it
* set autoconfig on: Now runconfig will be called everytime the editor is loaded
* set autoconfig on: Now runconfig will be called everytime the editor is loaded
==== Want custom keybindings? ====
You have the power. In your config.js (run: editconfig) simply add in the keybindings you know and love.
E.g. Fancy having Ctrl+U to nuke an entire line?
Simple add:
    // equiv of the command line: bindkey ctrl u killLine
    document.fire("bespin:editor:bindkey", {
        modifiers: "ctrl",
        key: "u",
        action: "killLine"
    });


==== Like Emacs keybindings? ====
==== Like Emacs keybindings? ====

Revision as of 06:02, 1 March 2009

We want to make Bespin as discoverable as possible, but there are already lots of little tips and tricks, so we wanted a place to hold them:

Ctrl-J: Jumping from Editor to Command Line

We love using the keyboard to navigate and often find ourselves jumping from the editor to the command line and back. To do this easily, simple use Control-J.

Ctrl-L: Center selected line

Fancy centering up? Ctrl-L and you the current selected line will be put front and center

Ctrl-K: Kill line

Remember the pico vs. vi wars? Ctrl-K to nuke the line away.

Work with projects

As of 0.1.2 "Narky Nimbus", you can run some new commands such as:

  • createproject projectName
  • deleteproject projectName
  • renameproject currentName newName
  • mkdir path projectname

Open in a new tab

If you are in the dashboard and want to open a file from the Open Sessions, or from the file chooser, just SHIFT+DOUBLE+CLICK.

How can I tie my own code into the editor? How can I extend it?

One way yo inject your own code to change the experience is via the special BespinSettings/config.js file.

You can read more at the config integration area: Labs/Bespin/Roadmap/ConfigIntegration

The key pieces are:

  • config.js: This file exists in your special BespinSettings directory
  • editconfig: This command will open the file up for tweaking
  • runconfig: This command will load up the config.js and run it
  • set autoconfig on: Now runconfig will be called everytime the editor is loaded

Want custom keybindings?

You have the power. In your config.js (run: editconfig) simply add in the keybindings you know and love.

E.g. Fancy having Ctrl+U to nuke an entire line?

Simple add:

   // equiv of the command line: bindkey ctrl u killLine
   document.fire("bespin:editor:bindkey", {
       modifiers: "ctrl",
       key: "u",
       action: "killLine"
   });

Like Emacs keybindings?

We have some emacs keybindings available if you type in "set keybindings emacs" on the command line:

   document.fire("bespin:editor:bindkey", {
       modifiers: "ctrl",
       key: "b",
       action: "moveCursorLeft"
   });
   document.fire("bespin:editor:bindkey", {
       modifiers: "ctrl",
       key: "f",
       action: "moveCursorRight"
   });
   document.fire("bespin:editor:bindkey", {
       modifiers: "ctrl",
       key: "p",
       action: "moveCursorUp"
   });
   document.fire("bespin:editor:bindkey", {
       modifiers: "ctrl",
       key: "n",
       action: "moveCursorDown"
   });
   document.fire("bespin:editor:bindkey", {
       modifiers: "ctrl",
       key: "a",
       action: "moveToLineStart"
   });
   document.fire("bespin:editor:bindkey", {
       modifiers: "ctrl",
       key: "e",
       action: "moveToLineEnd"
   });