Home > vim > Different tabs for different files

Different tabs for different files

Problem:

Needed to have different tabs for different files when editing with vim. Eg in python tab == 4 spaces, in a MakeFile tab == tab.

Solution:

Added this to ~/.vimrc

" Use different indentation for yaml files
 autocmd FileType yaml,yml setlocal tabstop=2 expandtab shiftwidth=2 softtabstop=2

 " In makefiles, don't expand tabs to spaces, since actual tab characters are
 " needed, and have indentation at 8 chars to be sure that all indents are tabs
 autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=0

Source:
https://superuser.com/questions/632657/how-to-setup-vim-to-edit-both-makefile-and-normal-code-files
https://github.com/spf13/spf13-vim/issues/789#issuecomment-118369177

Advertisements
Categories: vim Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: