There are cases when you want (for many
reasons), to add same text to the beginning of multiple lines. This
may happen when you are coding (say python) and then you
realise that you need to enclose your function within a class. So you
add the class definition at the start of the module file. You then
need to indent the function, as python requires. To indent you need
to add four spaces (or your preferred number). In vi, you do this
like so;
- Go to the starting line that you intend to prepend your desired character(s).
- Press Ctrl + V
- Press the down arrow or Enter/Return key to the last line that you intend to prepend your desired character(s)
- Press Shift + i (lowercase i )
- Enter the character(s). In our python example, this would be the desired number of spaces (I usually use four)
- Then press the Esc key one.
- Your entered characters should appear in a few seconds.