Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6213471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:42:08+00:00 2026-05-24T06:42:08+00:00

I happen to work on code in which some modules use tabs for indentation

  • 0

I happen to work on code in which some modules use tabs for indentation while others use spaces. Many text editors such as Np++ has some sort of an adaptive tabbing feature, which use spaces for indentation if the previous line (or block of code) use spaces, or tabs as the case may be.

I haven’t seen anything in vim like this. Is there any such plugin or setting for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:42:09+00:00Added an answer on May 24, 2026 at 6:42 am

    I perfer to set my enviroment up like the below example demonstrates. I make a general rule of replacing tabs with spaces and use augroup when I need to override that rule. Makefiles are a good example of when you may require TABS and a cpp file is when you may require spaces.

    " A tab produces a 4-space indentation
    :set softtabstop=4
    :set shiftwidth=4
    :set expandtab
    " replace tabs with spaces unless noted otherwise
    
    " <snip>
    
    augroup CPPprog
       au!
       "-----------------------------------
       " GENERAL SETTINGS
       "-----------------------------------
       au BufRead,BufNewFile,BufEnter             *.cpp,*.c,*.h,*.hpp   set nolisp
       au BufRead,BufNewFile,BufEnter             *.cpp,*.c,*.h,*.hpp   set filetype=cpp
       au FileType                                *                     set nocindent smartindent
       au FileType                                *.c,*.cpp             set cindent
       au BufRead,BufNewFile,BufEnter             *.cpp                 let g:qt_syntax=1
       " turn on qt syntax highlighting (a plugin)
       au BufNewFile,BufRead,BufEnter             *.c,*.h,*.cpp,*.hpp   let c_space_errors=1
       " trailing white space and spaces before a <Tab>
    
       " <snip>
    
    augroup END
    
    " <snip>
    
    augroup filetype
      au! BufRead,BufNewFile,BufEnter *Makefile*,*makefile*,*.mk set filetype=make
    augroup END
    " In Makefiles, don't expand tabs to spaces, since we need the actual tabs
    autocmd FileType make set noexpandtab
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of dissassembled code which didn't work quite well around some
I happen to come across a Java code at my work place. Here's the
I am using some code which was originally taken from the Apple sample ViewTransitions
I'm creating a small code plugin which allows you to do some things with
I have placed together some code which converts strings into data, and then places
Consider the following R code (which, I think, eventually calls some Fortran): X <-
What happen if web.config gets updated while ASP (ASP.NET 2.0) server still process client
I wanted to test the following code (which works fine for a non-null list)
The full text of the error is: TemplateSyntaxError at / Caught an exception while
I'm stuck with some syntax on figuring out which of 2 buttons in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.