Block comment for bash script in vi editor
- In vi editor, comment from line n to m
- <ESC>
- :n,ms/^/#/
- From line n to m substitute line start (^) with # sign
- To remove comment
- <ESC>
- :n,ms/^#//
- From line n to m substitute line start (^) followed by # with nothing //
Almost universal with /bin/bash for vi editor
There seems to be a problem... How are we to determine what line is what line... Count one by one? That's nuts~! But, there is a solution...
vi / vim editor does show line number
- To display line numbers along the left side of the editor, type in the following command
- <ESC>
- :set number OR :set nu
- To undo the line numbers
- <ESC>
- :set nu! OR :set number!
The above is just a one time thing. To make a permanent change for set number
- Terminal# vi ~/.vimrc
- In vi/vim editor
- set number
- Save and exit
- Note: if you are curious on where is the file located, it may not be there. So just create the file and where will follow. Note of note: Only the user profile you create/edit the file will have the change.
Reference
http://www.cyberciti.biz/faq/vi-show-line-numbers/http://stackoverflow.com/questions/947897/block-comments-in-a-shell-script
No comments:
Post a Comment