Your browser does not support JavaScript!
Upvotes Anonymous 13 User 0

How to comment/uncomment code in Spacemacs

Add a layer
Add evil-commentary as a layer:
Open a code file
I chose a JavaScript file:
Comment a single line
Put your cursor on a line, and press g c c:
You can use the same shortcut to uncomment the line.
Comment using Vim motions
You can type g c followed by a Vim motion to comment sections of code. 

For example, we can comment out three lines with g c 3 j: 
Comment a visual mode selection
You can use v to enter visual mode and select text (hjkl):
Then press g c to toggle comments:
Documentation
See the documentation for more shortcuts.
Was this helpful?

Tags

Comments

Byanonymous Anonymous 0 User 0
Your spacemacs tips are most welcome, thanks!

Leave a Comment

I agree to the Terms of Service
Design © 2015, Downranked, LLC.,
Original user code contributions under MIT License