visual-studio-code - 允许自动缩进二维数组(如表格)的编辑器或扩展
问题描述
我正在寻找一个允许我自动格式化这样的数组的编辑器或插件(最好是 VS Code):
const lines = [
[ "step-1", "step", "step-1", "", `["1"]` ],
[ "r", "repeater", "r", "", `[]` ],
[ "mycheckbox__1[]", "input", "mycheckbox[]", "__1", `[]` ],
[ "myradio__1", "input", "myradio", "__1", `[]` ],
[ "mytext__1", "input", "mytext", "__1", `[""]` ],
[ "myurl__1", "input", "myurl", "__1", `[""]` ],
[ "myemail__1", "input", "myemail", "__1", `[""]` ],
[ "myselect__1", "input", "myselect", "__1", `[""]` ],
[ "mymultiselect__1[]", "input", "mymultiselect[]", "__1", `[]` ],
[ "myfile__1", "input", "myfile", "__1", `[""]` ],
[ "mymultifile__1[]", "input", "mymultifile[]", "__1", `[""]` ],
[ "mycheckbox__2[]", "input", "mycheckbox[]", "__2", `[]` ],
[ "myradio__2", "input", "myradio", "__2", `[]` ],
[ "mytext__2", "input", "mytext", "__2", `[""]` ],
[ "myurl__2", "input", "myurl", "__2", `[""]` ],
[ "myemail__2", "input", "myemail", "__2", `[""]` ],
[ "myselect__2", "input", "myselect", "__2", `[""]` ],
[ "mymultiselect__2[]", "input", "mymultiselect[]", "__2", `[]` ],
[ "myfile__2", "input", "myfile", "__2", `[""]` ],
[ "mymultifile__2[]", "input", "mymultifile[]", "__2", `[""]` ],
[ "r_count", "input", "r_count", "", `["1"]` ],
[ "root-mycheckbox[]", "input", "root-mycheckbox[]", "", `[]` ],
[ "root-myradio", "input", "root-myradio", "", `[]` ],
[ "root-mytext", "input", "root-mytext", "", `[""]` ],
[ "root-myurl", "input", "root-myurl", "", `[""]` ],
[ "root-myemail", "input", "root-myemail", "", `[""]` ],
[ "root-myselect", "input", "root-myselect", "", `[""]` ],
[ "root-mymultiselect[]", "input", "root-mymultiselect[]", "", `[]` ],
[ "root-myfile", "input", "root-myfile", "", `[""]` ],
[ "root-mymultifile[]", "input", "root-mymultifile[]", "", `[""]` ],
[ "step-2", "step", "step-2", "", `["2"]` ],
];
更可读的东西,像这样:
const lines = [
[ "step-1", "step", "step-1", "", `["1"]` ],
[ "r", "repeater", "r", "", `[]` ],
[ "mycheckbox__1[]", "input", "mycheckbox[]", "__1", `[]` ],
[ "myradio__1", "input", "myradio", "__1", `[]` ],
[ "mytext__1", "input", "mytext", "__1", `[""]` ],
[ "myurl__1", "input", "myurl", "__1", `[""]` ],
[ "myemail__1", "input", "myemail", "__1", `[""]` ],
[ "myselect__1", "input", "myselect", "__1", `[""]` ],
[ "mymultiselect__1[]", "input", "mymultiselect[]", "__1", `[]` ],
[ "myfile__1", "input", "myfile", "__1", `[""]` ],
[ "mymultifile__1[]", "input", "mymultifile[]", "__1", `[""]` ],
[ "mycheckbox__2[]", "input", "mycheckbox[]", "__2", `[]` ],
[ "myradio__2", "input", "myradio", "__2", `[]` ],
[ "mytext__2", "input", "mytext", "__2", `[""]` ],
[ "myurl__2", "input", "myurl", "__2", `[""]` ],
[ "myemail__2", "input", "myemail", "__2", `[""]` ],
[ "myselect__2", "input", "myselect", "__2", `[""]` ],
[ "mymultiselect__2[]", "input", "mymultiselect[]", "__2", `[]` ],
[ "myfile__2", "input", "myfile", "__2", `[""]` ],
[ "mymultifile__2[]", "input", "mymultifile[]", "__2", `[""]` ],
[ "r_count", "input", "r_count", "", `["1"]` ],
[ "root-mycheckbox[]", "input", "root-mycheckbox[]", "", `[]` ],
[ "root-myradio", "input", "root-myradio", "", `[]` ],
[ "root-mytext", "input", "root-mytext", "", `[""]` ],
[ "root-myurl", "input", "root-myurl", "", `[""]` ],
[ "root-myemail", "input", "root-myemail", "", `[""]` ],
[ "root-myselect", "input", "root-myselect", "", `[""]` ],
[ "root-mymultiselect[]", "input", "root-mymultiselect[]", "", `[]` ],
[ "root-myfile", "input", "root-myfile", "", `[""]` ],
[ "root-mymultifile[]", "input", "root-mymultifile[]", "", `[""]` ],
[ "step-2", "step", "step-2", "", `["2"]` ],
];
我找了一些在线工具,但没有找到。虽然有一些扩展来格式化 CSV 文件,但首先将我的代码转换为有效的 CSV 文件,然后使用查找和替换添加括号有点麻烦。
所以目前,如果它们不是太大,我仍然会手动标记这样的数组。不过,在我的代码编辑器中拥有一个自动格式化工具会很酷。
解决方案
我在您的代码上尝试了这个扩展,它运行良好: Smart Column Indenter
这个扩展提供了命令,例如extension.smartColumnIndenter.indentN
默认绑定到键绑定的命令: ++Ctrl所以你可以使用它或重新绑定它,而不是像我在演示中那样使用上下文菜单。I CtrlN
推荐阅读
- python-3.x - 如何在python的json文件中获取特定用户ID的所有详细信息
- vb.net - 启动浏览器,输入 url,用脚本或 vb.net 输入用户名和密码
- android - 将 Native 代码与 CameraX 集成到自定义 React Native 组件失败
- c# - 我应该在框架更新到新版本时重新发布我的项目吗?
- excel - 如何将条件应用于另一个文件中两个日期之间有多个值的 vlookup 值?
- php - 如何使用 PHP 在现有多维数组中过滤 10 分钟前的数组
- dart - 如何保护我的颤振应用程序及其用户登录凭据
- wordpress - /blog 和 /newsletter 上的自动分页在末尾添加斜杠
- powershell - PowerShell 对象属性递归
- bixby - 如何通过bixby在段落中文本溢出省略号