Indiana University
University Information Technology Services
  
What are archived documents?
Login>>
Login

Login is for authorized groups (e.g., UITS, OVPIT, and TCC) that need access to specialized Knowledge Base documents. Otherwise, simply use the Knowledge Base without logging in.

Close

Using the vi editor, how can I automatically indent lines?

To automatically indent lines using the vi editor, set the autoindent flag:

  1. If you are currently in insert or append mode, press Esc.

  2. Press  :  (the colon). The cursor should reappear at the lower left corner of the screen beside a colon prompt.

  3. Enter the following command: set autoindent

Now, when you are inserting text, if you press Enter at the end of your text, vi will automatically indent the next new line to match the indent of the previous one. This is useful for editing tables with indented columns or program source code.

To turn off the automatic indentation, follow the preceding instructions; however, in step 3, at the colon prompt, enter:

set noautoindent

Normally vi will "forget" the particular setting you've chosen once you've left the editor. You can make either setting take effect automatically whenever you use vi on a particular account by placing the appropriate set statement as a line in a file in your home directory named .exrc.

For a list of all current settings, at the colon prompt, enter:

set all

At Indiana University, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?

This is document afcw in domain all.
Last modified on May 13, 2009.

I need help with a computing problem

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.



Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

I have a comment for the Knowledge Base

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.