Editor config - how to align the code

你说的曾经没有我的故事 提交于 2019-12-11 08:49:23

问题


I'm using VS Code and for formating my code I use a formatter CTRL + SHIFT + I. It works fine, but I would like to be able to format my code to be align in this way:

before:

export const apiConfig = { protocol: 'https', url: 'www.example.com', timeoutSec: 15 }

after:

export const apiConfig = { protocol: 'https', url: 'www.example.com', timeoutSec: 15 }

Any way to set it up? Any specific setting for .editorconfig?


回答1:


What you are asking for is impossible to easily achieve in one go within VScode and completely unrelated to .editorconfig, as it only governs rather basic features — by design.

You will need to use the formatting in combination with an alignment plugin like this: https://marketplace.visualstudio.com/items?itemName=steve8708.Align

If you feel adventurous, you may be able to hack together a solution which runs both commands in sequence at the push of a keyboard shortcut. However, VScode is not as readily scriptable in this regard as for example Vim is.



来源:https://stackoverflow.com/questions/47472907/editor-config-how-to-align-the-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!