为了账号安全,请及时绑定邮箱和手机立即绑定

请问 sublime alignment插件怎么用?

请问 sublime alignment插件怎么用?

小新在编程 2016-08-17 23:36:38
    我下载了 sublime  alignment插件, 也配置了Setting-user 文件, 但就是不起作用,更改了快捷键 ctrl + alt +f , 请问用过这个插件的朋友们是怎么弄的? 谢谢!
查看完整描述

3 回答

?
CandyBullet

TA贡献4条经验 获得超2个赞

快捷键冲突了,你更改了之后还是冲突。

继续改快捷键吧。

查看完整回答
反对 回复 2018-01-28
?
Bangk

TA贡献34条经验 获得超21个赞

Sublime Alignment 主要用于代码对齐,最新版据说已经集成了这个插件,你不妨下载Sublime3试试

具体部署:

左上角Sublime Text -> Preferences -> Package Settings ->Alignment 如果没有最后的"Alignment"选项,说明你还没有安装此插件。

这里面有5个选项:

Settings- Default

Settings- User

Settings- Syntax Specific - User

Key Bildings - Default

Key Bildings - User

带有后缀Default的,为默认设置,每次升级插件都会重置这里的设置。所以尽量不要修改这里,否则升级会丢失你原先的设置。

带有后缀User的,为用户自定义设置,你可以把Default里面的设置全部复制一份到这里,然后再修改,这里存在的设置选项会覆盖Default里面的,即User的优先级更高。

Key Bildings为快捷键设置,默认的快捷键很有可能因为和其他快捷键冲突而无效, 所以及可以在Key Bildings - User里重新设置(格式可以仿照Default里的写法)。
此快捷键是用来 实现对齐的。

默认设置Settings- Default:

{
    // If the indent level of a multi-line selection should be aligned
    "align_indent": true,

    // If indentation is done via tabs, set this to true to also align
    // mid-line characters via tabs. This may cause alignment issues when
    // viewing the file in an editor with different tab width settings. This
    // will also cause multi-character operators to be left-aligned to the
    // first character in the operator instead of the character from the
    // "alignment_chars" setting.
    "mid_line_tabs": false,

    // The mid-line characters to align in a multi-line selection, changing
    // this to an empty array will disable mid-line alignment
    "alignment_chars": ["="],

    // If the following character is matched for alignment, insert a space
    // before it in the final alignment
    "alignment_space_chars": ["="],

    // The characters to align along with "alignment_chars"
    // For instance if the = is to be aligned, there are a number of
    // symbols that can be combined with the = to make an operator, and all
    // of those must be kept next to the = for the operator to be parsed
    "alignment_prefix_chars": [
        "+", "-", "&", "|", "<", ">", "!", "~", "%", "/", "*", "."
    ]
}

"align_indent":开关量,默认为true,  true,则把选择的多行的 不同缩进级别也变成相同的缩进(最大的缩紧级别)flase,只是对齐,不改变缩进级别

"mid_line_tabs"开关量,默认为false。如果你的文本是使用Tab键缩进排版,设置该变量为true时,那么该插件在对齐文本的时候也使用Tab键来对齐缩进。但是这样可能会出现问题,因为Tab键在不同的编辑器上代表的空格数可能不同(Sublime 是代表4个空格), 当你使用别的编辑器打开该文件时,简而言之,就是排版可能就不是对齐的了。

"alignment_chars"即对齐字符这是一个数组,可以这样设置多个字符:alignment_chars": ["=","*","a"]
默认只有“=”字符,即alignment_chars": ["="]
数组里面的字符就是放在中线对齐的字符。

"alignment_space_chars"和"alignment_chars"一样,也是数组格式 默认值包含“=”号,即:alignment_space_chars": ["*","="]就是这个数组包含上面"alignment_chars"里的字符, 对齐后,在其前面增加一个空格。如果这里不包含"alignment_chars"里的字符,对齐后,在其前面没有空格。可以这样说, "alignment_space_chars"数组是"alignment_chars"数组的子集。

"alignment_prefix_chars"前缀字符 对齐字符(即alignment_chars"里的字符),可以拥有前缀字符。例如"="号字符前可以拥有以上字符作为前缀

可按照以上的参数说明,自己增加对齐的字符来增强功能。
我一般需要在对齐字符前面增加一个空格,
所以我一般就保持alignment_chars 数组和 alignment_space_chars数组一致。即在所有的对齐字符前面都增加一个空格。

查看完整回答
反对 回复 2016-08-30
  • 3 回答
  • 0 关注
  • 13566 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信