Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'd recommend https://github.com/tpope/vim-commentary for commenting out code. Anyway, it's not a good practice.


What would you recommend for turning off a section of code temporarily?


For C:

    #if 0
    ...code...
    #endif


You could try a plugin I wrote to quickly comment/uncomment blocks of code:

https://github.com/Jaymon/vim-commentify

It's a no frills plugin that only does one thing, but it does it pretty well.


Kill region, save, run/compile/read, undo if needed. With undo tree (or if you add commit to the process above) there is no need to comment just one region to turn off something.

Optionally, convert the region into a separate function/method and just don't call it while checking.


You still didn't explained why it wasn't a good practice. This just sounds impractical.


Commented code (as in, working code commented out, not comments in code) eventually rots/becomes cruft that at some point in time is going to bite you (or someone else in your team, or some maintainer in the future)


Yeah, "not a good practice" (i.e. "the user is wrong" or "why would you want to do that?") is the lazy way of justifying software deficiencies.


I use emacs, so deficiencies on how vim handles anything do not mean much to me, actually.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: