Skip to content

Instantly share code, notes, and snippets.

@steveoh
Created January 31, 2017 00:07
Show Gist options
  • Save steveoh/2e04dd381ba60653ce5d9f04ad922dd0 to your computer and use it in GitHub Desktop.
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.
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