comment and uncomment code inline
It's very useful to be able to comment out a block of code in a quick edit. And likewise to uncomment the code. This operation often involves multi-line stanzas and even large blocks. With just line-wise navigation and insert mode this would cost you about 4 keystrokes per line. Master this hole of VimGolf and you'll quickly drop your key count in day to day Vim as well.
Start file
These first three lines should be commented out with C-style inline comments. // These three lines should have // the C-style insline comment // characters removed.
End file
// These first three lines should // be commented out with C-style // inline comments. These three lines should have the C-style insline comment characters removed.
View Diff
1,3c1,3 < These first three lines should < be commented out with C-style < inline comments. --- > // These first three lines should > // be commented out with C-style > // inline comments. 5,7c5,7 < // These three lines should have < // the C-style insline comment < // characters removed. --- > These three lines should have > the C-style insline comment > characters removed.
Solutions
The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!
Check out these helpful resources to improve your Vim skills... Game on.
#320 Thomas Gebert / @realtombert - Score: 35 - 09/29/17 @ 15:43
qa0i// <Esc>jq@a@@jqa0xxx<Esc>qj@@j@@<Esc><Esc>:wq<CR>
0 comments