10

I'm editing this code:

callFunction({
    x: somearray,
});

Then I want to extract somearray to be a variable with a copy. I cut somearray and delete the colon, then enter (_ is the cursor):

const x = [..._
callFunction({
    x
});

Then yank, and the super helpful web-mode screws up my code:

const x = [...somearray_
    callFunction({
        x
    });

Then I close the bracket and have to reindent the function call expression.

How to disable this autoindenting after yank?

Disabling electric-indent-local-mode does not help. Neither does setting electric-indent-inhibit to t. Searching for "web-mode disable auto-indent" does not lead to a solution.

1 Answer 1

12

You might want to try setting web-mode-enable-auto-indentation to nil:

(setq web-mode-enable-auto-indentation nil)

An issue was filled about this a while ago (and there were probably other ones, it's not worth searching for these). It doesn't seem to be documented well, so it's not easy to find the option.

2
  • Such an obvious thing. Thank you.
    – Arry
    Commented Jun 16, 2019 at 12:40
  • 3
    Thanks - how the web-mode author him/herself didn't go crazy yanking some data on an incomplete line... (to then do something about it, like have this "feature" disabled by default!)
    – Déjà vu
    Commented Oct 9, 2019 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.