Last active
December 6, 2020 11:01
-
-
Save JayRaparla/1d55a40f21626dc10f5f142f71abf811 to your computer and use it in GitHub Desktop.
Atom's init.coffee file with interesting commands for frequent use
This file contains 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
# Your init script | |
# | |
# Atom will evaluate this file each time a new window is opened. It is run | |
# after packages are loaded/activated and after the previous editor state | |
# has been restored. | |
# | |
# An example hack to log to the console when each text editor is saved. | |
# | |
atom.workspace.observeTextEditors (editor) -> | |
editor.onDidSave -> | |
console.log "Saved! #{editor.getPath()}" | |
#Command to delete empty lines | |
atom.commands.add 'atom-workspace', 'lines:delete-whitelines', -> | |
buffer = atom.workspace.getActiveTextEditor().getBuffer() | |
newLines = buffer.getLines().filter (line) -> line isnt '' | |
buffer.setText newLines.join '\n' | |
#command to delete single line comments of the format '//' only from any file | |
## need to improving this reg-ex overtime to include different types of comments and handle cases such as comments inside comments | |
## and false positives like'//' matching http:// | |
atom.commands.add 'atom-workspace', 'lines:delete-singleLineComments', -> | |
commentPattern = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/; | |
buffer = atom.workspace.getActiveTextEditor().getBuffer() | |
newLines = buffer.getLines().filter (line) -> !line.match( commentPattern ) | |
buffer.setText newLines.join '\n' | |
## keep adding more |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in your opnion, there 's a way to assign some bash commands in the init.coffe so that a Conda environment can be activated as soon as atom is launched?