In a CSS file, this line is in more than 5 rules.
border: 1px solid black;
I want to comment this line like this:
/*border: 1px solid black;*/
Is there a shortcut to do this comment for all 5 occurrence?
Can I assign a key to comment a single line or a block of lines?
I don’t want to search and replace this only line, i want to set a key so that when i hover a line and press that key, that line will be commented or selecting a line or selecting a block of line, if i press that key, that line or block of line will be commented.
I would suggest using a macro for this. Macros are automatically saved by Vim and available across sessions.
To record a macro type:
q<letter><commands>q. Where<letter>is any letter from a-z and indicates the register in which the macro will be saved. After that you simply type the commands you wish to be recorded and finally pressqagain to stop recording.In your case you could do the following. Press
q, then pressato select thearegister, next enter insert mode and enter the/*and*/at the beginning and end of a line. Pressqagain to stop recording.Now simply move the cursor to any line and press
@ato execute the macro on that line.