question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird auto-formatting of code upon paste

See original GitHub issue

Description

In JS files this extension will sometimes mess up indentation upon pasting. The circumstances under which this seems to happen is when having "editor.formatOnPaste": true enabled (something that Atom Keymap adds to your config automatically).

With prettier extension disabled:

vscode_prettier_ok This is when having prettier disabled. I start out by marking the text and pressing CMD+C, place the cursor where I want to paste, and CMD+V. Everything pastes as one would expect.

With prettier extension enabled and including trailing comma

vscode_prettier_fail This is after enabling prettier. Again, I mark the text, copy it, paste it. Split second after pasting prettier has formatted everything in a horrific manner.

With prettier extension enabled an excluding trailing comma

I then found out that if I do not mark the last comma in the selection I want to copy+paste, it works even with prettier enabled.

vscode_prettier_enabled_ok

Snippet:

module.exports = ({ config }) => {
  return [
    {
      key: 'some value',
      fn: async (req, res) => {
        return 'some value'
      },
    },
  ]
}

My config:

{
  "workbench.colorTheme": "Oceanic Next Italic",
  "window.nativeTabs": true,
  "editor": {
    "formatOnSave": true,
    "fontFamily": "Fira Code",
    "fontSize": "16",
    "fontLigatures": true,
    "tabSize": 2,
    "tabCompletion": true,
  },
  "prettier": {
    "singleQuote": true,
    "semi": false,
    "trailingComma": "es5",
    "printWidth": 100
  },
  // added by atom keymap
  "atomKeymap.promptV3Features": true,
  "editor.multiCursorModifier": "ctrlCmd",
  "editor.formatOnPaste": true
  // end atom keymap
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:29
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

68reactions
gabrielmickocommented, Jun 28, 2018

I think "editor.formatOnPaste": false, fixed my issue.

26reactions
SYGINTcommented, Jun 7, 2018

I’m still experiencing this issue with the latest extension 1.5.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Odd formatting when pasting text from web
My Word documents have some weird text formatting going on when pasting anything that's been copied from the web, and it happens randomly ......
Read more >
How to disable auto-formatting on paste?
Hello.I'm using latest pyCharm 2.6.3If i copy-paste code from one source code file to another, pyCharm seems to apply auto formatting: it...
Read more >
Odd code snippet formatting when pasting snippets into a ...
I'm noticing my code snippets are formatted in undesirable ways when I paste them into a code block - incorrect spacing is the...
Read more >
Settings to copy paste with correct indentation in Visual Studio ...
A simple fix is to try Ctrl + Shift + V after copying the code.
Read more >
How to Strip Formatting When You Copy and Paste Text: 5 Ways
Here's how to copy and paste without formatting, on both Windows and Mac, using several convenient methods.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found