When we are coding we have to comment out some blocks of code and uncomment those time to time. It is easy with IDE like eclipse, netbeens, Visual Studio. I recently moved to vim and here is how to comment and uncomment in gvim. (lets assume character "#" is used for line commenting)
Method 1
Command mode of vim used for this.Use this command to comment lines from 10 to 15 with "#"
:10,15s/^/#
Use this command to uncomment lines commented before.
:10,15s/^#/
Method 2
VISUAL BLOCK mode is used for this.- First, move the cursor to the first char of the first line in block code you want to comment. Then press Ctrl + v to enter VISUAL BLOCK mode
- Then move cursor with arrow keys to the end of code block that want to comment.
- Then press Shift + i and cursor will come to the begining of code block
- The type the commenting character. In this case "#".
- Final press Esc and it will comment out the block you marked
do the same things but instead of type Shift + i, you just type x to remove all # after highlight them in VISUAL BLOCK mode.
No comments:
Post a Comment