Is there a plugin or a built-in feature in Vim that allows for elastic tabstops? I've searched a bit, and I found some references saying it was not possible in Vim, but those were quite old.

Is there a way to have elastic tabstops in Vim? I am fine with a solution for Neovim as well, as that's what I use anyway.


As far as I can tell there is no reasonable way to accomplish this in a plugin.

There is a patch for it, but it's hard to predict when / if the patch will get merged.

  • 6
    Anybody, if you want this to be merged, please cheer for it at vim-dev (and also reply back how well this works for you) – Christian Brabandt Apr 18 '15 at 12:06
  • 2
    This patch doesn't seem to actually be elastic tabstops. Instead it's variable tabstops, but you have to set up the stop points ahead of time. This is nice in its own way but not really what the question is about. – Caleb Mar 7 '16 at 10:29
  • @Caleb, you could probably script something, once var tabstop patch has been merged. – Christian Brabandt Mar 7 '16 at 18:54
  • @Christian no you couldn't. See the discussion around the web but this can't be done as a script/plugin in vim (even with the variable with tabstop patch) because it only keeps one method to render all lines with. It just doesn't expose what you would need to make this work. – Caleb Mar 7 '16 at 19:17
  • 5
    The mentioned patch has been merged as of 8.1.105 – Christian Brabandt Jun 25 '18 at 8:16

From the comments: since version 8.1.105, vim has +vartabs compile-time feature, thanks to Christian Brabandt !

As far as I can see, this allows implementing elastic tabstops. See the actual pull request.

  • 1
    You could link to the docs or explain how it could be implemented. That might help future readers more than the link to the user who mentions it. – Lucas Jul 23 '18 at 12:50
  • 2
    :set vartabstop=4,20,10,8 - This will make the first tab 4 spaces wide, the second 20 spaces, the third 10 spaces, and all following tabs 8 spaces. – pdwalker Dec 17 '18 at 11:38
  • 2
    vartabstop isn't sufficient for elastic tabstops, because the tabstops can't vary between code blocks. vartabstop applies to the entire file. – Aron Griffis Feb 14 '19 at 3:12

Your Answer

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

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