Labs/Bespin/Tips

From MozillaWiki
< Labs‎ | Bespin
Jump to: navigation, search

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:

Important Shortcut Keys

NOTE: Cmd == the Apple key on a Mac, and the Ctrl key on Windows / Linux.

Cmd-J: Jump to the Command Line

To get to the command line, simply type Cmd-J. To get back to the editor, use Escape.

Cmd-O: Open File Browser

The file browser is a good way to look at the files and folders that you have in the cloud. Cmd-O will give you access to the file system and you can go from there.

Cmd-I: Quick Open

Cmd-I will open a quick way to jump to any file in a given project. The quick open window will jump up and you can start searching. It will remember your recent files for quick access.

Cmd-L: Goto Line

Opens the command line with the "goto " command seeded. Simply type the line that you wish to jump to and you will be sent there.

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.

Useful Commands

Work with project

project [command] [parameters]
Command
Description
Parameters
create
create a new project
[projectname]
delete
delete a project
[projectname]
export
export the given project with an archivetype of zip or tgz
[project] [archivetype]
help
show subcommands for project command
[search]
import
If a URL is given, import that URL (e.g. project import http://foo.com/bar.zip MyProject). If only a project is given, then a file upload dialog will ask to upload a local file (e.g. project import MyProject).
[url] [project]
list
show projects

rename
rename a project
[currentProject] [newProject]
show
show the current project


How to configure

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

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

You can read more at the config integration area.

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"
   });

Virtual vs. Physical lines, what do you prefer? set strictlines on

By default, you can click the mouse on any area in the editor and you will be allowed to start typing there. If at the end of a line and you hit the right arrow, you will go right anyway. This is the virtual mode that is default.

Many people (Dion included) prefer a physical approach where if you click too far to the right the cursor is placed on the last character. If you move to the right at the end of a line you go to the beginning of the next line. Etc.

To get this mode, simple type: "set strictlines on"

Match indentation from the previous line? set autoindent on

When you are coding, when you hit return, you often want the cursor to match your indentation level. By default this isn't turned on yet, but to get this mode, simply type: "set autoindent on"