Skip to content

Instantly share code, notes, and snippets.

@mihow
Last active February 11, 2017 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihow/94907cf05b0f20219f78abe4b3a975b6 to your computer and use it in GitHub Desktop.
Save mihow/94907cf05b0f20219f78abe4b3a975b6 to your computer and use it in GitHub Desktop.
Refactor from functions to class functions by adding `self` to all function arguments (VIM search and replace command)
# For functions with existing arguments
:%s/def \(.\+\)(\(.\+\)):/def \1(self, \2):/
# For functions with no arguments
:%s/def \(.\+\)():/def \1(self):/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment