Vetur: formatOnPaste

Created on 22 Mar 2017  路  11Comments  路  Source: vuejs/vetur

With "editor.formatOnPaste": true in settings, when I paste, the code goes on a new line and the indentation messes up; if I go one step back with Ctrl+Z it looks good. Thanks.

bug formatting

Most helpful comment

This is not fixed on 0.6.10
formatting problem vetur

formatting problem vetur 2

All 11 comments

Screenshots please otherwise I wouldn't know what you are talking about.

paste

Think that's fixed in 0.6.5.

This is not fixed on 0.6.10
formatting problem vetur

formatting problem vetur 2

I'm also still experiencing this bug with the latest version of Code and the latest plugin version 0.8.5.

It's very annoying. Any chance at a fix? Or perhaps a way to disable the formatting altogether?

You can disable native auto formatting for vue files
"[vue]": { "editor.formatOnPaste": false }

@rebornix If I remember correctly you were doing this feature, right?
Is this a bug on Vetur side or VSCode side?

The root problem is, Vetur is given the copy-pasted text for formatting like so:

    <div>
      <span>test</span>
    </div>

Vetur would remove all leading whitespace so it becomes:

<div>
  <span>test</span>
</div>

@HerringtonDarkholme I'm thinking about dropping the range formatter and only provide a whole-doc formatter. Like in vueServerMain from connection.onDocumentRangeFormatting to connection.onDocumentFormatting. This would also stop VSCode from triggering Vetur's formatter for formatOnPaste.

One use case was selecting a whole region, like <style> and use the range formatting. But anything containing incomplete parts of multiple regions aren't handled well now. So I don't think it's that useful.
A whole-doc formatter is easier to maintain. And we can provide vetur.format.[html/css/js].disable so people can turn specific formatter off, if they don't like its style.

@octref Agree.

Do you want to include this change in #363 ?

I can do that myself. For #363 I added a comment -- let's keep it simple and pull it in first.

Or if you want to open a separate PR. I'll start doing emmet then.

Was this page helpful?
0 / 5 - 0 ratings