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

  • Home
  • SEARCH
  • 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 37609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:34:39+00:00 2026-05-10T14:34:39+00:00

How do I prevent vim from replacing spaces with tabs when autoindent is on?

  • 0

How do I prevent vim from replacing spaces with tabs when autoindent is on?

An example: if I have two tabs and 7 spaces in the beginning of the line, and tabstop=3, and I press Enter, the next line has four tabs and 1 space in the beginning, but I don’t want that…

  • 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. 2026-05-10T14:34:40+00:00Added an answer on May 10, 2026 at 2:34 pm

    It is perhaps a good idea not to use tabs at all.

    :set expandtab 

    If you want to replace all the tabs in your file to 3 spaces (which will look pretty similar to tabstop=3):

    :%s/^I/   / 

    (where ^I is the TAB character)

    From the VIM online help:

    'tabstop' 'ts'      number  (default 8)         local to buffer Number of spaces that a <Tab> in the file counts for.  Also see |:retab| command, and 'softtabstop' option.  Note: Setting 'tabstop' to any other value than 8 can make your file appear wrong in many places (e.g., when printing it).  There are four main ways to use tabs in Vim: 1. Always keep 'tabstop' at 8, set 'softtabstop' and 'shiftwidth' to 4    (or 3 or whatever you prefer) and use 'noexpandtab'.  Then Vim    will use a mix of tabs and spaces, but typing <Tab> and <BS> will    behave like a tab appears every 4 (or 3) characters. 2. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use    'expandtab'.  This way you will always insert spaces.  The    formatting will never be messed up when 'tabstop' is changed. 3. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use a    |modeline| to set these values when editing the file again.  Only    works when using Vim to edit the file. 4. Always set 'tabstop' and 'shiftwidth' to the same value, and    'noexpandtab'.  This should then work (for initial indents only)    for any tabstop setting that people use.  It might be nice to have    tabs after the first non-blank inserted as spaces if you do this    though.  Otherwise aligned comments will be wrong when 'tabstop' is    changed. 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I want to prevent users from using the enter key unless they are
Is it possible to prevent an asp.net Hyperlink control from linking, i.e. so that
Does TCP/IP prevent multiple copies of the same packet from reaching the destination? Or
How do I prevent my users from accessing directly pages meant for ajax calls
How can I prevent a user from resizing GridViewColumns withing a ListView control?
How can I prevent the user from being able to resize an image in
In Vim, how do I break a line of text with a newline? For
Hello (Prevent website url in print from javascript?) I am sure some simple solution
How would you prevent a browser from timing out while a long process is
I want to prevent banned users from logging in to the site and give

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.