0

I am using js2-mode right now. I am working on a .js file that contain a ES6 multi like string like this:

Vue.component("comment", {
    props: {
        comment: {
            type: Object,
            required: true
        }
    },
    template: `this is a multiline string,
it should be aline to the top!
`
});

How to fix the indent problem in the template at the end? (tab is not working inside the string, and the two ` should be aligned)

  • 2
    This indentation behavior makes sense, as your string would otherwise contain potentially unwanted spaces. Lines inside of multi-line strings aren't indented for that reason. You could try using something like align-regexp to align these lines manually. – user12563 Jul 9 '19 at 8:51
  • Ok but then it's really annoying to write nested html template (have to use space manually) because tab is not working inside the string. – Ben Boyer Jul 9 '19 at 8:58
  • 1
    Have you looked at web-mode or mmm-mode? – nega Jul 9 '19 at 13:25
  • Yes web-mode does seems to do the job well! I am amazed about how much usefullness this pakage cover for webdev. – Ben Boyer Jul 10 '19 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.