How to comment out a block of Python code in VIM

Posted by Rishabh Manocha on Stack Overflow See other posts from Stack Overflow or by Rishabh Manocha
Published on 2010-04-01T15:14:46Z Indexed on 2010/04/02 5:33 UTC
Read the original article Hit count: 477

Filed under:
|
|

I was wondering if there was any key mapping in VIM to allow me to indent certain lines of code (whether those lines have been selected in visual mode, or n lines above/below current cursor position).

So basically something that converts the following

def my_fun(x, y):
    return x + y

to

#def my_fun(x, y):
#    return x + y

I am ok with using either # or """ for commenting out the relevant lines. Ideally, I would also like the same keymapping to uncomment the lines if the given lines have been commented out.

Thanks

© Stack Overflow or respective owner

Related posts about vim

Related posts about python