How can 2-space indenting be shown as 6 column tab-style indents when editing, while remaining as 2-spaces?


  • a team uses a convention of 2 spaces for indenting code
  • I prefer indenting of 6 columns (and in my own separate work OUTSIDE this project use tab characters)

I have attempted something like: autocmd BufNewFile,BufRead **project*/*,*project* setlocal expandtab shiftwidth=2 softtabstop=2 tabstop=6 autoindent


<2-real-space-characters>teh code

should show as:

<6-space-characters, so 3x more indentation visually>teh code

I cannot figure out how to have 2-space indenting display as 6 columns for greater code-block differentiation, if this is even possible. Thanks for any answers, comments, redirects, insights shared.

  • You want to make spaces display as tabs? Natively, this seems unlikely. One solution would be to convert to tabs, work, and then reconvert to spaces, but there are so many edge cases i wouldnt even know where to begin. – D. Ben Knoble Oct 19 '18 at 3:31
  • 1
    Possible duplicate of How to change the displayed indentation amount? You'll obviously have to change the constants involved because you want to triple rather than double the indent. – Rich Oct 19 '18 at 8:33
  • 1
    Just retracted my close vote. Re-reading my answer on the linked question, I've realised it won't easily work for displaying 2 real spaces as 6 columns, because it works by displaying single-width characters as double-width characters. You could probably hack it to display 2-spaces as 3 columns by using a more complicated regular expression, but anything past 4 is impossible using that approach. If you want the functionality you describe you're probably going to have to edit the content of the file as @D.BenKnoble suggests. – Rich Oct 19 '18 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.