Sublime Text 2 : Python – Search And Replace Tips(Regual Expression)

Here is some tips and tricks that I used to clean my python scripts before putting it for code review. These are some very basic of search and replace that you can do in Sublime Text 2. Improve these as you needed and you can speed up your work by some margin.

  1. Add Space between comma(,) and a letter
    Find What : “,((?! ).)”
    Replace With : “, $1”
  2. Adding Space before and after operators(+, *, -, /, =)
    Find What : “((?! ).)(+|*|-|/|=|%)((?! ).)”
    Replace With : “$1 $2 $3”
  3. Remove space after “(“
    Find What : “(()( )”
    Replace With : “$1”
  4. Remove space before “)”
    Find What : “( )())”
    Replace With : “$2”
  5. Remove space at the end of line
    Find What : “(.)( )(n)”
    Replace With : “$1$3”

Published by

Barish Chandran

Have got over 12 years of experience in Animation and VFX industry in Particle Effects, Lighting and Programming areas. I started my animation career as Dynamic FX artist and I have credit in more than 30 movie and CGI Series. Then started developing tools and programs for Animation. Now am working as Pipeline Software Developer Lead at MPC.

Leave a Reply

Your email address will not be published. Required fields are marked *