My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
EditorKeyBindingsFeatures  
This page details keybindings and other features of a clojure editor
Updated Jan 15, 2012 by laurent....@gmail.com

Clojure Editor Features Detail

Edition modes

Conventions

  • (foo |bar) represents the text (foo bar) with the cursor before the b
  • (foo |bar|) represents the text (foo bar) with the word bar selected

Default Structural Edition Mode

  1. The features in this mode are carefully chosen because they do not surprise or block newcomers to Structural Edition.

Win/Linux Mac Description Example(s)
<Enter> <Enter> auto-indentation
Win/Linux Mac Description Example(s)
( without selection ( without selection create a new balanced pair foo| ==> ( ==> foo (|)
[ without selection [ without selection create a new balanced pair foo| ==> [ ==> foo [|]
{ without selection { without selection create a new balanced pair foo| ==> { ==> foo {|}
Win/Linux Mac Description Example(s)
Shift+Alt+Up Shift+Command+Up expand selection to enclosing form (foo [bar b|az]) ==> Shift+Alt+Up ==> (foo [bar |baz|]) ==> Shift+Alt+Up ==> (foo |[bar baz]|) ==> Shift+Alt+Up ==> |(foo [bar baz])|
Shift+Alt+Left Shift+Command+Left expand selection to sibling form on the left (or, if no sibling form on the left, to the enclosing form) (foo b|ar baz) ==> Shift+Alt+Left ==> (foo |bar| baz) ==> Shift+Alt+Left ==> (foo| bar| baz) ==> Shift+Alt+Left ==> (|foo bar| baz) ==> Shift+Alt+Left ==> |(foo bar baz)|
Shift+Alt+Right Shift+Command+Right expand selection to sibling form on the right (or, if no sibling form on the right, to the enclosing form) (foo b|ar baz) ==> (foo |bar| baz) ==> (foo |bar |baz) ==> (foo |bar baz|) ==> |(foo bar baz)|
Shift+Alt+Down Shift+Command+Down restore previous selection (foo bar| baz|) ==> Shift+Alt+Left ==> (foo |bar baz|) ==> Shift+Alt+Down ==> (foo bar| baz|)
Win/Linux Mac Description Example(s)
( with selection ( with selection wrap the selection with parens (foo |(bar baz)|) ==> ( ==> (foo (|(bar baz)))
[ with selection [ with selection wrap the selection with square brackets (foo |(bar baz)|) ==> [ ==> (foo [|(bar baz)])
{ with selection { with selection wrap the selection with curly braces (foo |(bar baz)|) ==> { ==> (foo {|(bar baz)})
Win/Linux Mac Description Example(s)
" inside code without selection " inside code without selection creates an empty litteral string foo |bar ==> " ==> foo "|" bar
" around code selection " around code selection wraps the selection in double quotes foo |bar| ==> " ==> foo |"bar"|
" when already inside a string literal " when already inside a string literal inserts an escaped double quote foo "bar |baz" ==> " ==> foo "bar \"|baz"
" inside a string literal, at the end " inside a string literal, at the end jumps outside the string literal foo "bar baz|" ==> " ==> foo "bar baz"|
Win/Linux Mac Description Example(s)
Ctrl+Alt+A Command+Alt+A Go to begin of current or previous top-level form
Ctrl+Alt+E Command+Alt+E Go to end of current or next top-level form
Ctrl+Alt+T (Ctrl+Alt+H deprecated) Command+Alt+T Select current or following top-level form
Win/Linux Mac Description Example(s)
??? <Home> Command+Left Go to left sibling form [todo] (foo [bar b|az]) ==> Home ==> (foo [bar |baz]) ==> Home ==> (foo [bar| baz]) ==> (foo [|bar baz])
??? <End> Command+Right Go to right sibling form [todo] (fo|o {bar baz}) ==> End ==> (foo| {bar baz}) ==> End ==> (foo |{bar baz}) ==> End ==> (foo {bar baz}|)
??? Ctrl+<Home> Command+Up Go right before the parent form [todo] (foo {[bar ba|z] blah}) ==> Ctrl+Home ==> (foo {[bar |baz] blah}) ==> Ctrl+Home ==> (foo {|[bar baz] blah}) ==> Ctrl+Home ==> (foo |{[bar baz] blah}) ==> Ctrl+Home ==> |(foo {[bar baz] blah})
Win/Linux Mac Description Example(s)
Alt+R ??? Alt+R Raise a form over its parent form (replace parent with current selection). Works with empty selections too (spy |(+ x y) z|) blah ==> Alt+R ==> |(+ x y) z| blah ; but also: (spy (+ x y) |z) blah ==> Alt+R ==> |z blah
Alt+S ??? Alt+S Split enclosing form or string (aaa |bbb) ==> Alt+S ==> (aaa)| (bbb) ; but also "aaa|bbb" ==> Alt+S ==> "aaa"| "bbb"`
Alt+J ??? Alt+J Join two sibling forms of same type (when cursor is between the forms) "aaa bbb"| "ccc ddd" ==> Alt+J ==> "aaa bbb|ccc ddd"; but also: [3 4]| [5 6 7] ==> Alt+J ==> [3 4| 5 6 7]

Strict Structural Edition Mode

  1. In addition to the features of the Default Structural Edition Mode, this mode does its best to prevent you from breaking the structure of your code
  2. Note: You'll only feel "at home" in this mode if you know the following commands

Win/Linux Mac Description Example(s)
<Tab> <Tab> hit with the cursor anywhere in a line, will reindent the line
Win/Linux Mac Description Example(s)
) without selection ) without selection jump after the closing paren of the nearest surrounding form-in-parens (foo ([bar b|az])) ==> ) ==> (foo ([bar baz])|)
] without selection ] without selection jump after the closing square bracket of the nearest surrounding form-in-square-brackets (let [a (inc |b) c d] blah) ==> ] ==> (let [a (inc b) c d]| blah)
} without selection } without selection jump after the closing curly bracket of the nearest surrounding form-in-curly-brackets {:a [:b (inc |c)] :e :f} ==> } ==> {:a [:b (inc c)] :e :f}|
Win/Linux Mac Description Example(s)
<Delete> <Delete> suppress chars but jumps over opening and closing parens/square brackets/curly brackets if they are non-empty ; will suppress the whole parens/brackets at once if empty and (currently) right before the closing part foo| (bar) baz ==> <Delete> ==> foo|(bar) baz ==> <Delete> ==> foo(|bar) baz ==> <Delete> ==> foo(|ar) baz ==> <Delete> ==> foo(|r) baz ==> <Delete> ==> foo(|) baz ==> <Delete> ==> foo| baz
<Backspace> <Backspace> suppress chars but jumps over closing and opening parens/square brackets/curly brackets if they are non-empty ; will suppress the whole parens/brackets at once if empty and (currently) right after the opening part foo (bar)| baz ==> <Backspace> ==> foo (bar|) baz ==> <Backspace> ==> foo (ba|) baz ==> <Backspace> ==> foo (b|) baz ==> <Backspace> ==> foo (|) baz ==> <Backspace> ==> foo | baz

Interaction with the REPL

REPL stands for "Read Eval Print Loop" an is the clojure/lisp equivalent of so called "interactive shells" of dynamic languages.

Win/Linux Mac Description
Ctrl+Alt+X Command+Shift+X Evaluate current selection or top-level form in the visible REPL (see Note below)
Ctrl+Alt+S Command+Alt+S Loads the saved version of the currently edited file (via load-file)
Ctrl+Alt+K Command+Alt+K Compiles the file (must correspond to a lib, thus having a (ns) declaration at its top
Shift+Alt+X C ??? Shift+Alt+X C Launch a new REPL and automatically loads the edited file into it (note:
Shift+Alt+D C ??? Shift+Alt+D C Launch a new REPL in debug mode and automatically loads the edited file into it
Ctrl+T ??? Ctrl+T automatic (run-tests) for namespace declared by editor, or namespace with same prefix as namespae declared by editor and ending with -test

Note:

  • if the visible REPL corresponds to another project than the project containing the edited file, one of the REPLs (if any) corresponding to the active file will be brought to front

Powered by Google Project Hosting