vi - turn off indent

When I tap return in vi, it indents a bunch of tabs, I want to turn this off. No indents (no tabs, no spaces) how?

ps: AWS doesn’t have this annoyance.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @smeeth,

What @Yannek mentioned is pretty good. I just wanted to popin and give a bit more information. You can disable auto-indentation for particular file types; the following example shows how to do this for html files.

Create the file ~/.vim/indent/html.vim containing the single line:

let b:did_indent = 1

This creates a user-specific indent script which will be loaded before the file type indent script. Auto indenting for the particular file type is disabled because well-behaved indent scripts do nothing if the buffer-local variable b:did_indent is defined (that variable indicates that the current buffer already has script-based indenting enabled).

You need to use the correct name for the file type (html in the above). If you are not sure what that name is, edit a file where you want to remove auto-indentation (for example, my.htm), then enter the following command to display the value of the ft (filetype) option for the current buffer:

:set ft?

Regards, KFSys

Hi, You can turn off auto-indenting executing :set noautoindent in vi. But this is a temporary solution, just for current editing session. In your case, it looks like there is some vi configuration saved in your droplet. So, there are at least three places where you can search for vi configuration.

1. Configuration file .exrc in your home directory


2. Configuration file .exrc in your working directory

Bear in mind that .exrc file is hidden, so to list it you must use ls command with parameter -a, e.g.

ls -a ~/

3. Environment variable EXINIT. This variable consists of a sequence of one or more vi configuration commands. You can simply check if it is set displaying its value.

echo $EXINIT

Then, if you found any vi configuration saved, you need to change it for non-auto-indenting.

1. If you found the configuration file .exrc, open it in an editor, search for autoindent string within its content, and replace it with noautoindent.

2. If you have vi configuration stored under environment variable, you can change its value

export EXINIT=$(echo $EXINIT | sed "s/autoindent/noautoindent/")