0

I'm not really sure if I should post this as a web browser question (or nginx), but I compose in VIM so here it is!

Because I don't like 8 character tabs in my documents, I set by tabstops to 4, shiftwidth to 4 and turn on autoindent so that when I do bullets things are the way they do them.

set shiftwidth=4
set tabstop=4
set autoindent

If I dump my txt file on a web server (like nginx) and open the text file served out by the webserver, I noticed that my tabs are interpreted as 8 characters and not 4.

Can somebody explain to me exactly what is going on, and how I might (if there even is one) modify my VIM settings (or nginx?) so that the text that is rendered looks like what I see in VIM when I am editing or viewing?

thanks!

2
  • 1
    Welcome to Vim. If you have the solution to your problem it is best to leave your question and post an answer such that other can follow or answer on their own. Commented May 7, 2022 at 17:36
  • 1
    Yea thanks I’ll do that!
    – Danathar
    Commented May 7, 2022 at 19:28

2 Answers 2

2

A tab character is a tab character. Any front-end has to choose how to display it. Your browser will choose to represent \t as 8 characters.

0

Problem Solved. Seems that the action of posting a stack exchange article was all I needed!

The answer is to use set expandtab so that tabs are ALWAYS spaces. I hope somebody somewhere finds this useful!

3
  • You probably only want to change tabstop if you are using literal tabs; it affects (mostly) the display width of the tab character. For spaces, shiftwidth + expandtab + softtabstop is a better combo
    – D. Ben Knoble
    Commented May 7, 2022 at 22:48
  • I’ve didn’t know about softtabstop. What does that do?
    – Danathar
    Commented May 8, 2022 at 0:00
  • 2
    Try :help 'softtabstop' :)
    – D. Ben Knoble
    Commented May 8, 2022 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.