Vim: autoindent with == doesn't work as expected

  • 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.


What did you do?

When I have this code in Python:

def someFunction(arg1):


print('this should indent') 

And when in normal mode with my cursor on the line print('this should indent') and press ==

What did you expect to happen?

Indent of four spaces

What happened instead?

Nothing

Technical details:

  • VSCode Version: 1.11.2
  • VsCodeVim Version: 0.6.18
  • OS: windows

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 85
  • Comments: 37 (13 by maintainers)

Commits related to this issue

Most upvoted comments

It’s nearly 2022 now, is there any way to reindent the current line correctly ??

@vegerot I assume you mean it should behave the same as Reindent selected lines. We use Format selection, which handles many more scenarios. You’re free to remap it to the former yourself, but I don’t see how leveraging VSCode’s formatting is the wrong approach.

But is == really supposed to format? The default behavior in vim seems to be to reindent current line from what I can find, might be wrong though.

I agree with @albheim. If the behavior is to mimic vim, = should really mean reindent, not reformat.

@madchap you can try editor.action.reindentselectedlines, but there’s no good solution to this on our end. Formatting is done by each language’s extension, and we just invoke the commands. https://github.com/VSCodeVim/Vim/issues/1017#issuecomment-569801348 is relevant.

The problem is there are two types of formatters in VS Code:

  • selection formatter (format the selected part)
  • document formatter (format the whole document)

When extensions only have document formatter, and you try to format a selection (such as Vue and Go), the message no formatter for x file found shows up. I have opened up an issue on VS Code side to provide a more meaningful message.

So what is the actual solution here? As of today, I have the issue as well.

I also have the issue that @xvjiarui describe Sorry, but there is no formatter for 'go'-files installed.

NOTE

  • the gofmt command line works
  • vscode editor.action.formatDocument works a expected

the issue is when I use = to format the code. I have tried to set the value of go.formatTool to gfmt, goreturns but still I get the notice “Sorry, but there is no formatter for ‘go’-files installed.”

I have disabled all other extension and re-installed vscodevim, without any results.

thanks

have the same issue with vue, it prompts that Sorry, but there is no formatter for 'vue'-files installed.