Created
January 31, 2017 00:07
-
-
Save steveoh/2e04dd381ba60653ce5d9f04ad922dd0 to your computer and use it in GitHub Desktop.
an atom command to remove common python debug statements. open your atom config folder. possibly rename init.cson to init.js and place this your file.
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
atom.commands.add('atom-text-editor', 'custom:remove-debug', () => { | |
const editor = atom.workspace.getActiveTextEditor(); | |
const range = editor.getBuffer().getRange(); | |
const checkpoint = editor.createCheckpoint(); | |
const regex = new RegExp(/\s*from nose.tools import set_trace\s*set_trace\(\)$|\s*import pdb;?\s*pdb.set_trace\(\)$/, 'gmi'); | |
editor.backwardsScanInBufferRange(regex, range, (iterator) => { | |
iterator.replace(''); | |
}); | |
editor.groupChangesSinceCheckpoint(checkpoint); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment