-
-
Save BenGitsCode/dd4daad9ed8f5ff292244ab182ed0864 to your computer and use it in GitHub Desktop.
An atom command and keymap to quickly end lines with semicolons. Only applies for javascript files. Code is based from turbo-javascript package.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open up your atom's init script file and add the following lines, then restart atom. | |
path = require 'path' | |
endLine = (insertNewLine) -> | |
editor = atom.workspace.activePaneItem | |
if path.extname(editor.getPath()) is '.js' | |
editor.getCursors().forEach((cursor) -> | |
editor.moveCursorToEndOfLine() | |
line = cursor.getCurrentBufferLine().trim() | |
if line && ';({,=?:'.indexOf(line[line.length - 1]) is -1 | |
editor.insertText(';') | |
) | |
if insertNewLine | |
editor.insertNewlineBelow() | |
atom.workspaceView.command 'easy-semicolon:end-line', -> endLine(false) | |
atom.workspaceView.command 'easy-semicolon:end-new-line', -> endLine(true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open up your atom's keymap file and add the following lines. | |
# This will overwrite the default cmd-enter, but should still work the same for file types other than js. | |
'.workspace .editor:not(.mini)': | |
'cmd-enter': 'easy-semicolon:end-new-line' | |
'cmd-;': 'easy-semicolon:end-line' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment