1 | # Atom editor integration
|
2 |
|
3 | These are just suggestions for an emacs addict who wants to try Atom editor.
|
4 |
|
5 | Packages to install:
|
6 | * __atom-macros__: Allow to define quick functions you can assign to keys.
|
7 | * __atom-keyboard-macros__: Recording macro like the F3/F4 in Emacs. Here you will use `Ctrl-X (` to start recording, `Ctrl-x )`
|
8 | to end recording and `Ctrl-x e` to execute it.
|
9 | * __language-toloframework-xjs__: Grammar for XJS files.
|
10 |
|
11 | Then go to he menu `Packages -> Macros -> Edit macro definitions` and put this in the opened file (backticks are mandatory to insert Javascript into CoffeeScript):
|
12 | ```coffee
|
13 | `
|
14 | function getActivePathAndExtension() {
|
15 | var activeEditor = atom.workspace.getActiveTextEditor();
|
16 | if( !activeEditor ) return null;
|
17 | var path = activeEditor.getPath();
|
18 | var dotPos = path.lastIndexOf( '.' );
|
19 | if( dotPos < 0 ) return null;
|
20 | return { ext: path.substr( dotPos ), path: path.substr( 0, dotPos ) };
|
21 | }
|
22 |
|
23 | function switchTo( ext ) {
|
24 | var info = getActivePathAndExtension();
|
25 | if( !info ) return;
|
26 | atom.workspace.open( info.path + ext );
|
27 | }
|
28 |
|
29 | this.tfwSwitchToJS = function() { switchTo( '.js' ); }
|
30 | this.tfwSwitchToXJS = function() { switchTo( '.xjs' ); }
|
31 | this.tfwSwitchToCSS = function() { switchTo( '.css' ); }
|
32 | this.tfwSwitchToINI = function() { switchTo( '.ini' ); }
|
33 | this.tfwSwitchToDEP = function() { switchTo( '.dep' ); }
|
34 | this.tfwSwitchToVERT = function() { switchTo( '.vert' ); }
|
35 | this.tfwSwitchToFRAG = function() { switchTo( '.frag' ); }
|
36 | `
|
37 | ```
|
38 |
|
39 | To get usefull key bindings to switch between JS, XJS, CSS, ... Go to the menu `File -> Keymap` and put this in the opened file:
|
40 | ```coffee
|
41 | 'atom-text-editor':
|
42 | 'alt--': 'editor:fold-all'
|
43 | 'alt-+': 'editor:unfold-all'
|
44 | 'ctrl--': 'editor:fold-current-row'
|
45 | 'ctrl-+': 'editor:unfold-current-row'
|
46 | 'f12 j': 'macros:tfwSwitchToJS'
|
47 | 'f12 x': 'macros:tfwSwitchToXJS'
|
48 | 'f12 c': 'macros:tfwSwitchToCSS'
|
49 | 'f12 i': 'macros:tfwSwitchToINI'
|
50 | 'f12 d': 'macros:tfwSwitchToDEP'
|
51 | 'f12 v': 'macros:tfwSwitchToVERT'
|
52 | 'f12 f': 'macros:tfwSwitchToFRAG'
|
53 | ```
|