有什么好的代码文件内容自动整理工具吗?

2019-11-26 15:04:50 +08:00
 CrazyRain0001

包含功能

1562 次点击
所在节点    问与答
10 条回复
rain0002009
2019-11-26 15:48:48 +08:00
prettier ?
Rwing
2019-11-26 15:53:31 +08:00
vs 有个功能叫 code cleanup
hei1000
2019-11-26 17:07:31 +08:00
写脚本?

我的一个简单的命令行, 放在脚本里面可以添加一些其他的功能, 当然了, 要利用自己的 vim/nvim 配置比如保存文件时"删除行尾多余空格"
~~~
nvim -es -c 'args ./**/*.cpp | argdo execute "normal gg=G" | update'
~~~
gwy15
2019-11-26 17:20:58 +08:00
看你啥语言了,
C 系:clang-format
py:autopep8
CrazyRain0001
2019-11-26 17:30:02 +08:00
@rain0002009 看了下介绍,是 js 代码格式化的?
CrazyRain0001
2019-11-26 17:30:53 +08:00
@Rwing 没找到
Rwing
2019-11-26 17:31:58 +08:00
CrazyRain0001
2019-11-26 17:33:09 +08:00
@hei1000 自动对齐和文件格式转换感觉用脚本不好写
CrazyRain0001
2019-11-26 17:50:14 +08:00
@Rwing 好吧~看了下貌似 vs2019 的 c#才支持的

>For C# code files, Visual Studio 2019 has a Code Cleanup button at the bottom of the editor (keyboard: Ctrl+K, Ctrl+E) to apply code styles from an EditorConfig file or from the Code Style options page. If an .editorconfig file exists for the project, those are the settings that take precedence.
hei1000
2019-11-26 17:51:44 +08:00
@CrazyRain0001 #8

看我上面"normal gg=G"就是自动对齐的

格式转换的话利用 iconv 之类的命令转换, 不过貌似 iconv 得提供源 Encoding, 你先获取一下, 全都放到脚本里面就行了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/623286

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX