Vim: O uses wrong indentation style (spaces instead of tabs)

Created on 4 May 2017  路  13Comments  路  Source: VSCodeVim/Vim

  • Click thumbs-up 馃憤 on this issue if you want it!
  • Click confused 馃槙 on this issue if not having it makes VSCodeVim unusable.

The VSCodeVim team prioritizes issues based on reaction count.


Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

Environment:

  • VSCode Version: 1.12 (1.11 too I think)
  • VsCodeVim Version: 0.6.20
  • OS: Ubuntu 14.04

What happened:

My file uses tab for indentations. If I have:

[TAB]some text

and my cursor is on that line, and then I press capital-O, I see

[SPACE][SPACE][CURSOR HERE]
[TAB]some text

What did you expect to happen:

I would have expected:

[TAB][CURSOR HERE]
[TAB]some text

How to reproduce it:

Follow the "What happened" section above. If the file indentation style is spaces, then capital-O uses spaces, which is the expected and observed behavior (no change needed there).

If I use the default SHIFT+CTRL+ENTER (regardless of insert or normal mode), it properly uses my indentation style (tabs).

kinbug statuneeds-more-info

All 13 comments

That's weird. Could you provide a sample of the file that causes this and your settings.json?

I can't get it to have incongruous behavior between shift+ctrl+enter and O.

Sample file, saved as x.js:

const myFunc = () => {
    const x = 1
}

Sample settings.json file:

{}

No, but seriously, I do have some settings. But for this, I removed all settings, and restarted VS code, and saw the same behavior (including SHIFT+CTRL+ENTER still behaving as expected).

I'm going to see if I can figure out how to record a giphy on Ubuntu to show this off, just to make sure I'm not missing something obvious.

Nah I got the same behavior. Thanks!

Actually, sorry, I was wrong. I can't replicate it. o and O do insert spaces for me on that file, but so do ctrl+shift+enter.

Can you try enabling the editor.renderWhitespace option and taking a screenshot?

Sure, here is the screenshot:

vscode_vim_1649_3

So I can't be sure about this (because I can't reproduce it), but the way I fixed "O" in https://github.com/VSCodeVim/Vim/pull/1663 should also hopefully fix this issue as well.

At the very least, it'll narrow down the issues.

Just wondering, does lowercase-o work fine?

I tested with VS Code 1.12.2 and Vim 0.7.1. Unfortunately, no change. Thanks for trying!

Yes, lowercase-o works fine as far as I can tell. I see a single tab (instead of two spaces) after the const x = 2 line if I lowercase-o on the const x = 2 line.

Ah, that new fix hasn't made its way into the release version yet, but I'm hopeful that it fixes the root of the issue.

I'll give you a heads up when the new release comes out.

Will this fix also solve an issue with == converting tabs to spaces (in a tab-configured environment), or is that a separate issue?

@bendman That's just weird. For "=" we're using the vim API call editor.action.formatSelection. What happens when you highlight the same selection and do ctrl+shift+pto call Format Selection?

@tylercollier We just pushed out a new release, so try that and see if it fixes your problems!

It's fixed. Hooray! Thanks!!

Was this page helpful?
0 / 5 - 0 ratings