–> exit insert mode and gets back to normal mode I –> capital I jumps to the beginning of row and gets into insert mode
For example comment first three lines with: I#j.j. Mode” is most probably not the most effective. If you want to be productive in Vim you need to talk with Vim with *language* Vim is using. The above command will comment out lines from 1 to 4. Step 3: Type the following to comment out the lines. Step 2: Set line numbers by typing: :set number This one is similar to Method 2 but slightly different. Let us go ahead and see the third method. Finally type the following command and hit ENTER at the Step 3: :1,3s/^#/Īfter uncommenting the lines, simply remove the line numbers by entering the following command: :set nonumber Open the file and set the line numbers as shown in Step 2. The same procedure can be used for uncommenting the lines in a file.
Step 5: To save the changes type :w or :wq to save the file and exit. Comment out multiple lines at once in Vim editor The lines from 1 to 4 have been commented out. In this case, we are commenting out the lines from 1 to 4. Step 3: Then enter the following command: :1,4s/^/#