UNPKG

2.07 kBMarkdownView Raw
1# Atom editor integration
2
3These are just suggestions for an emacs addict who wants to try Atom editor.
4
5Packages 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 )`
8to end recording and `Ctrl-x e` to execute it.
9* __language-toloframework-xjs__: Grammar for XJS files.
10
11Then 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`
14function 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
23function switchTo( ext ) {
24 var info = getActivePathAndExtension();
25 if( !info ) return;
26 atom.workspace.open( info.path + ext );
27}
28
29this.tfwSwitchToJS = function() { switchTo( '.js' ); }
30this.tfwSwitchToXJS = function() { switchTo( '.xjs' ); }
31this.tfwSwitchToCSS = function() { switchTo( '.css' ); }
32this.tfwSwitchToINI = function() { switchTo( '.ini' ); }
33this.tfwSwitchToDEP = function() { switchTo( '.dep' ); }
34this.tfwSwitchToVERT = function() { switchTo( '.vert' ); }
35this.tfwSwitchToFRAG = function() { switchTo( '.frag' ); }
36`
37```
38
39To 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```