Dave Taylor
Dave Taylor

Reputation: 2045

best way to use indent/javascript.vim within indent/html.vim for <script> tags

what's the best way to use indent/javascript.vim within indent/html.vim for tags

Edit: Appologies, as suggested I should really give a little more to go on so that you can help.

My vim settings can be found https://github.com/davetayls/vim-settings

I'm currently using html.vim from http://www.vim.org/scripts/script.php?script_id=2075 I'm using javascript.vim from http://github.com/pangloss/vim-javascript

Both of these are working really well for their prospective file types.

Thanks

Dave

Upvotes: 1

Views: 1078

Answers (1)

romainl
romainl

Reputation: 196789

What is the problem you are trying to solve? What doesn't work? What does?

You can tell Vim this file is an HTML+JS file (and thus take advantage of both language-specific sets of features) by issuing this command:

set filetype=html.javascript

If you are not satisfied with the default indent files you can search for a better one on the Vim website.

Someone has ported a cool Emacs feature called "narrowing" over to Vim. I've used it to debug large <style></style> and <script></script> portions in an old project. It's very nice.

I'll probably get a downvote but you should write your JavaScript in a separate *.js file. The benefits of doing this go well beyond fixing indentation problems in your editor (separation of concern, focus, maintainability, loading order, loading time…).

Upvotes: 4

Related Questions