vi comment and uncomment multiple lines
Comment multiple lines
- Press ESC
- Go to the starting line, press ctrl+v to enable visual block mode
- Use down arrow or k key to select multiple lines
- Press shift+I to enable insert mode
- Press # to add comment to first line, then press ESC, then wait for 1 second to get # added to all lines
Another option is:
- Press ESC
- Go to the starting line, press ctrl+v to enable visual block mode
- Use down arrow or k key to select multiple lines
- Press shift+ : to do search and replace ('<,'> will be automatically added)
- Type s/^/#/ to add # to comment out selected lines
Uncomment multiple lines
- Press ctrl+v to enable visual block mode
- Move down to select lines
- Press x to uncomment selected lines
No comments:
Post a Comment