Skip to content

Commit 5c1292a

Browse files
committed
Blog: Use html,css,js plugins for vue
1 parent da5cf49 commit 5c1292a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
layout: single
3+
title: Use HTML/CSS/JS plugins for VueJS files
4+
tags: [til]
5+
status: publish
6+
date: 2017-08-24 11:31:00 +0800
7+
type: post
8+
category: articles
9+
published: true
10+
---
11+
12+
Often vim plugins and configs activate for a certain `filetype`, so set
13+
your `filetype` in the current buffer. For example, I want currently want to use
14+
html highlighting and omni completion for `.vue`, you can do this in your `.vue` file:
15+
16+
{% highlight vim %}
17+
setlocal filetype=vue.html
18+
{% endhighlight %}
19+
20+
Even better, you can use `autocmd` so that you don't have to type it yourself
21+
every time you start editing a .vue file:
22+
23+
{% highlight vim %}
24+
autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html
25+
{% endhighlight %}
26+
27+
Word of warning though: Some plugins will scan through the whole files that might
28+
raise false alarms (e.g. linters). So doing something like this can cause problems:
29+
30+
{% highlight vim %}
31+
setlocal filetype=vue.html.css.javascript
32+
{% endhighlight %}
33+
34+
This can be useful for quick, one-off tasks like indentation.
35+
36+
I'll update as soon as I get better a better way of handling this,
37+
but I really like the no-vim-plugin solution for now.

0 commit comments

Comments
 (0)