[Tutor] Block highlighters in python

Steven D'Aprano steve at pearwood.info
Tue Apr 8 16:55:56 CEST 2014


On Tue, Apr 08, 2014 at 11:18:40AM +0530, Santosh Kumar wrote:
> Is there a way by which we can highlight a block in the python ?
> 
> i have a huge code and i want to see a block of ``if`` code. How do i
> achieve this in VIM or any other editor.
> 
> Note: In perl if i put my cursor on one "{" it will hightlight the other
> closed "}".
> 
> Do we have any such facility in python ?

This has nothing to do with Python, it is completely to do with the 
editing capabilities of your editor. If you are using Windows Notepad, 
it is very weak and has nearly no functionality. If you are using Emacs, 
it can do nearly anything, perhaps with a little bit of scripting.

I don't use Vim, so I cannot answer your question. But in my case, I 
always use four spaces for indents so I can easily see changes in indent 
level:

     # not this
     if condition:
      do_this()
      while condition:
       do_something()
      do_that()


     # make it obvious
     if condition:
         do_this()
         while condition:
             do_something()
         do_that()



-- 
Steven


More information about the Tutor mailing list