Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Shift+o doesn't respect indentation setting (when using Autoindent)

Open fschoenm opened this issue 1 year ago • 2 comments

Describe the bug My indentation is set to spaces. When using o to add a new line below the cursor, it starts indented with spaces but when pressing O (Shift+o) to add a line above the cursor, it sometimes uses tabs instead.

To Reproduce Steps to reproduce the behavior:

  1. Open a new file in VS Code, set indentation to spaces, enable "Vim: Autoindent", and use the following text:
def test():

····print("test")

····return
  1. Go to line 3.
  2. If I press o, a new line begins below the cursor and inserts spaces:
def test():

····print("test")
····|

····return
  1. If I press Shift+o instead, a new line begins above the cursor and inserts tabs:
def test():

→   |
····print("test")

····return

Expected behavior Respect the indentation setting in all cases.

Screenshots

Environment (please complete the following information):

  • Extension (VsCodeVim) version: v1.26.0
  • VSCode version: v1.83.0
  • OS: Windows 10

Additional context n/a

fschoenm avatar Oct 06 '23 08:10 fschoenm

I don't think I am able to reproduce this on 1.26.2.

If I use Shift+o it seems to do the behavior you suggest, but it is hard to say because the way VSCode deletes indentation. For example, if you open a new line, press space 8 times, then press backspace it will delete 4 spaces (depending on your settings). So it simulates deleting a 'tabwidth' even if you just typed in spaces.

seantwie03 avatar Nov 10 '23 12:11 seantwie03

If I am on a closing brace, and type shift-o it doesn't create the indentation for the code block just above. This is also true anywhere on the line where the closing brace is.

wmstack avatar Feb 16 '24 22:02 wmstack