简体   繁体   English

如何使Vim JavaScript漂亮的格式化程序插件运行?

[英]how can I make the vim javascript pretty formatter plugin run?

I downloaded jsbeautify.vim from http://www.vim.org/scripts/script.php?script_id=2727 我从http://www.vim.org/scripts/script.php?script_id=2727下载了jsbeautify.vim

So where do I put jsbeautify.vim ? 所以我应该把jsbeautify.vim放在哪里? In ~/.vim/ or ~/.vim/ftplugin/ ? 在〜/ .vim /或〜/ .vim / ftplugin /中?

After I position the plugin file, I will vim somefile.js containing javascript code without any newlines (difficult to read). 放置好插件文件后,我将在somefile.js中添加包含javascript代码且没有换行符(难以阅读)的vim。

How do I invoke the plugin to pretty the code make it readable (exactly what key sequence). 我如何调用该插件以使代码漂亮易读(确切地说是什么键序列)。

How do others read/edit large crunched javascript code files (like firefox or chrome extensions)? 其他人如何阅读/编辑大型的javascript代码文件(如firefox或chrome扩展名)?

Fyi: this is a chrome extension so the files are overly large to cut-paste into an web-based tool. Fyi:这是一个chrome扩展名,因此文件太大,无法剪切粘贴到基于Web的工具中。 I really just want to edit the file in-place to fix a bug, test theories. 我真的只想就地编辑文件以修复错误,测试理论。

Thanks, - Greg 谢谢,-格雷格

figured it out. 弄清楚了。

The file jsbeautify.vim must be placed in the ~/.vim/plugin/ directory. 文件jsbeautify.vim必须放置在〜/ .vim / plugin /目录中。

To invoke, do: 要调用,请执行以下操作:

vim somefile.js vim somefile.js

\\ff \\ FF

where the \\ char is your char. \\ char是您的char。 The default is backslash. 默认值为反斜杠。

also, you can run it by using: 另外,您可以使用以下命令运行它:

:call g:Jsbeautify() :call g:Jsbeautify()

Then you can edit and save the javascript file. 然后,您可以编辑并保存javascript文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM