Ⅰ. 插件描述
vue-beautifier for nodeⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'maranimatias/vue-formatter'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'maranimatias/vue-formatter'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'maranimatias/vue-formatter'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/maranimatias/vue-formatter
Ⅳ. 文档说明
# vue-formatter
vue-beautifier for node
npm install -g vue-formatterUsing
Cli
cat my-compnet.vue | vue-formatter | sponge my-compnet.vueor alternatively
cat my-compnet.vue | vue-formatter > my-compnet.vue.tmp && mv my-compnet.vue.tmp my-compnet.vueJavaScript
npm install vue-formatterconst formatter = require('vue-formatter');
const fs = require('fs');
fs.readFile('foo.vue', 'utf8', function (err, data) {
if (err) { throw err; }
console.log(formatter(data));
});Using on VIM
Key map on .vimrc
autocmd FileType vue noremap <buffer> <c-f> :%!vue-formatter<CR>Defaults options for JS-beautify
{
"indent_size": 2,
"indent_char": " ",
"indent_with_tabs": false,
"eol": "\n",
"end_with_newline": false,
"indent_level": 0,
"preserve_newlines": true,
"max_preserve_newlines": 3,
"space_in_paren": false,
"space_in_empty_paren": false,
"jslint_happy": true,
"space_after_anon_function": true,
"brace_style": "collapse,preserve-inline",
"break_chained_methods": false,
"keep_array_indentation": true,
"unescape_strings": false,
"wrap_line_length": 0,
"e4x": false,
"comma_first": false,
"operator_position": "before-newline"
}Donate
Bitcoin 3GonBQ8XibkL9d5SDu5j7MccavV1VKXXet
Ethereum 0xf3ca8c0630ceee045f715b5c596e70887a903d38
Monero 86sR1arBcYW918Bf8NhN3bCynwGfbzMna48KfsffHi8L1UEKqwu6FVRR3canexk3jfByB99gWB5bSFxvAt2ZneigLmSNxJB