I would like to insert a hash at the beginning of a selected block of text in VIM (ruby comment). I selected the lines in Visual Mode, but how do I perform the same operation to all lines?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You have two primary options:
Select in block visual mode (ctrl-v), then use
Ito insert the same thing along the left side of the entire block. SimilarlyAappends; see blockwise operators.Select the lines in normal visual (v) or visual line (V) mode, then run the same command on all of them, for example
s/^/# /ornormal I#. Typing:while you have a visual selection automatically uses the visual selection as the line range (denoted by'<,'>).