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”

Sublime Text 2 : The tag line become reality…


Sublime Text 2 is my favourite editor. It is one of the best editor I have ever used ever in my carrier. It have almost all the features a programmer need, and have lots of packages available to support the basic features. Sublime is released for linux, windows and Mac OS.

When I was a windows user, Notepad++ was my best matte. I moved to linux may be 4-5 years back, It was very difficult. Using vim, emac(traditional and best) or IDEs like eclipse, geany, aptana. I tried almost everything. Both of them gave me issues, moving to traditional linux editors was difficult for a windows user like me(honestly, still uses it for editing remote files.). Using IDEs makes me mad, lots of menus, option, dialog boxes, tabs, was confusing.

I came to know about Sublime Text 1-2 years back. First impression was like heaven, now onwards I never had to think about any other editor. “I DID FALL IN LOVE WITH IT“. A perfect replacement for Notepad++ in linux(personally sublime text 2 is better). Started using it in windows also and started suggesting others too.

Notepad++ Vs Sublime Text 2

It is unfair to compare both, both have their own features and cons. You can find tons of discussions regarding this in web, just a Google search “Notepad++ Vs Sublime Text 2” will do. I like Sublime more than Notepad++ now.

Some of the good features:

Goto Anything
Command Palette
Split Editing (The best one.)
Multiple Selections
Distraction Free Mode
Plug-in API
Customize Anything(Literally)
JSON Settings(Somewhere I saw this in cons, don’t know why.)

The Packages I mainly uses:

Package Control
Git Gutter
Maya Sublime
Sublime JEDI


Blackboard(Comes with sublime, Customized)


Sublime Text 2