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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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
~/.exrc
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/")
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.