Sublime Text 编辑器 插件 之 "Sublime Alignment" 详解
作者:shede333
主页:http://my.oschina.net/shede333
版权声明:原创文章,版权声明:自由转载-非商用-非衍生-保持署名 | [Creative Commons BY-NC-ND 3.0][]
#Sublime Text 编辑器 插件 之
"Sublime Alignment" 详解
Sublime Alignment 主要用于代码对齐,最新版据说已经集成了这个插件。 下载地址:
插件安装方式、以及较好的插件推荐,如下:
编码神器 Sublime Text 包管理工具及扩展大全 - 开源中国社区
Mac上的设置文件位置:
左上角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": [
"+", "-", "&", "|", "<", ">", "!", "~", "%", "/", "*", "."
]
}
##参数详解
下面为原始测试数据
int aa = 1;
char bb = 'a';
float fff = 2;
unsigned int d = 1;
###"align_indent":
开关量,默认为true,
- true,则把选择的多行的 不同缩进级别也变成相同的缩进(最大的缩紧级别),结果如下:
int aa = 1;
char bb = 'a';
float fff = 2;
unsigned int d = 1;
- flase,只是对齐,不改变缩进级别
int aa = 1;
char bb = 'a';
float fff = 2;
unsigned int d = 1;
###"mid_line_tabs"
开关量,默认为false。
如果你的文本是使用Tab键缩进排版,设置该变量为true时,那么该插件在对齐文本的时候也使用Tab键来对齐缩进。
但是这样可能会出现问题,因为Tab键在不同的编辑器上代表的空格数可能不同(Sublime 是代表4个空格), 当你使用别的编辑器打开该文件时,简而言之,就是排版可能就不是对齐的了。
###"alignment_chars"
即对齐字符
这是一个数组,可以这样设置多个字符:alignment_chars": ["=","*","a"]
默认只有“=”字符,即alignment_chars": ["="]
数组里面的字符就是放在中线对齐的字符。
如下面都把“=”排成一列中线对齐
int aa = 1;
char bb = 'a';
float fff = 2;
unsigned int d = 1;
例如设置里增加“*”号,即:alignment_chars": ["=","*"]
结果如下:
原文:
int *aa = 1;
char *bb = 'a';
float *fff = 2;
unsigned int *d = 1;
排列对齐后:(把“*”号排成对齐的一列)
int *aa = 1;
char *bb = 'a';
float *fff = 2;
unsigned int *d = 1;
###"alignment_space_chars"
和**"alignment_chars"**一样,也是数组格式 默认值包含“=”号,即:alignment_space_chars": ["*","="]
就是这个数组包含上面**"alignment_chars"里的字符, 对齐后,在其前面增加一个空格。
如果这里不包含"alignment_chars"**里的字符,对齐后,在其前面没有空格。
可以这样说, **"alignment_space_chars"数组是"alignment_chars"**数组的子集。
原文还在文章的起始处,这里设置包含“=”,
即alignment_space_chars": ["="],
结果如下:
int aa = 1;
char bb = 'a';
float fff = 2;
unsigned int d = 1;
这里设置不包含任何字符,
即alignment_space_chars": [],
结果如下:
int aa = 1;
char bb = 'a';
float fff = 2;
unsigned int d= 1;
###"alignment_prefix_chars"
即:前缀字符 默认设置:"alignment_prefix_chars": ["+", "-", "&", "|", "<", ">", "!", "~", "%", "/", "*", "."]
对齐字符(即alignment_chars"里的字符),可以拥有前缀字符。
例如"="号字符前可以拥有以上字符作为前缀。
原文设置如下:(这里的前缀字符有 "!"、"<"符号)
int aa = 1;
char bb != 'a';
float fff <= 2;
unsigned int d = 1;
对齐后如下:(即把前缀字符+对齐字符一起当作对齐字符来对待)
int aa = 1;
char bb != 'a';
float fff <= 2;
unsigned int d = 1;
##总结
可按照以上的参数说明,自己增加对齐的字符来增强功能。
我一般需要在对齐字符前面增加一个空格,
所以我一般就保持alignment_chars 数组和 alignment_space_chars数组一致。即在所有的对齐字符前面都增加一个空格。
转载自:https://my.oschina.net/shede333/blog/170536
Sublime Text 编辑器 插件 之 "Sublime Alignment" 详解的更多相关文章
- 全网最详细的Sublime Text 3的激活(图文详解)
不多说,直接上干货! 前期博客 全网最详细的Windows里下载与安装Sublime Text *(图文详解) ZYNGA INC. User License EA7E- 927BA117 84C93 ...
- 如何安装 Sublime text 编辑器相关的插件
Sublime是一个伟大的编辑器,具有可靠的基础功能,使编写代码变得愉快.您可以安装一个包管理器,以便于安装插件和添加新功能. 为什么使用包管理器(package manager) 包管理器可以方便地 ...
- 开发者最常用的 8 款 Sublime Text 3 插件
转载于:http://www.itxuexiwang.com/a/liunxjishu/2016/0228/177.html?1456925631Sublime Text作为一个尽为人知的代码编辑器, ...
- Sublime Text 最佳插件列表(转)
Package Control 安装方法 首先通过快捷键 ctrl+` 或者 View > Show Console 打开控制台,然后粘贴相应的 Python 安装代码. Sublime Tex ...
- 8款实用Sublime text 3插件推荐
Sublime Text作为一个尽为人知的代码编辑器,其优点不用赘述.界面整洁美观.文本功能强大,且运行速度极快,非常适合编写代码,写文章做笔记.Sublime Text还支持Mac.Windows和 ...
- 推荐!Sublime Text 最佳插件列表
本文由 伯乐在线 - 艾凌风 翻译,黄利民 校稿.英文出处:ipestov.com.欢迎加入翻译组. 本文收录了作者辛苦收集的Sublime Text最佳插件,很全. 最佳的Sublime Text ...
- Sublime Text 2 插件
一直以来写代码都是用的EditPlus,也尝试了一段时间学习Vim这神器,后来因为使用不习惯还是改回了原来的EditPlus.前几天朋友想我推荐了Sublime Text 2,喜欢尝鲜我的肯定是不会放 ...
- 转: sublime text常用插件和快捷键
Sublime Text 2是一个轻量.简洁.高效.跨平台的编辑器.博主之前一直用notepdd++写前端代码,用得也挺顺手了,早就听说sublime的大名,一直也懒得去试试看,认为都是工具用着顺手就 ...
- Sublime Text 最佳插件列表
http://blog.jobbole.com/79326/ 推荐!Sublime Text 最佳插件列表 2014/07/25 · 工具与资源 · 26.1K 阅读 · 2 评论 · Sublime ...
随机推荐
- node.js+mysql把数据显示到前端简单实例
原以为数据查出来了,要展示是鸡毛蒜皮的事儿!谁知道,我弄了一天....我错就错在没把connection.query里面. 下面的例子是可以的了! 看过我之前文章的同学,应该很熟悉下面的代码,对!主要 ...
- 常见Linux命令(非文件操作)
可见 http://man.linuxde.net/systemctl 非常详尽
- [Linux] Proc 文件系统
转载自:http://linux.chinaunix.net/doc/2004-10-05/16.shtml#324lfindex0 目录: /proc --- 一个虚拟文件系统 加载 proc 文件 ...
- 如何解决weblogic server启动中在IIOP后运行缓慢
WebLogic Server在Linux环境中,有时因为linux OS的安全包没有安装,导致weblogic server 在启动的时候会在长时间的停留在 <2/07/2009 08:54: ...
- Windows命令行的使用
在介绍Windows批处命令前,我们首先来介绍Windows命令行的使用. Windows shell提供了一个黑色的框框界面,即命令行操作界面,关于命令行的作用和好处,我就不费口舌了,下面仅窥见一斑 ...
- rsync运行时出现skipping non-regular file
如果执行 rsync 时提示 skipping non-regular file……,检查下原文件夹中是否包含软链接 修改下脚本文件: rsync -va ... -a == -rlptgoD (no ...
- Foreach控件使用
在SSIS中,Foreach控件可以循环处理选中的文件中的文件,例如sql文件,Excel文件等.下面就介绍一个比较经典的案例,将一个文件夹中包含的多个Excel文件循环导入至数据库中. 第一步:在数 ...
- [转] SQL Server 批量 停用/启用 外键约束
本文转自:http://hi.baidu.com/wangzhiqing999/item/ca699308de4f1ff9a1103429 今天百度知道上面,看到这样一个要求: 现在有一个库,有很多张 ...
- iOS:判断用户名是否以字母开头、手机号输入、邮箱是否正确的正则表达式
新建一个字符串分类:NSString(Check),定义类方法更方便 .h文件 #import <Foundation/Foundation.h> @interface NSString ...
- Tile based Rendering 二 tbr and tbdr 优化建议tiled based deferred rendering
http://www.seas.upenn.edu/~pcozzi/OpenGLInsights/OpenGLInsights-TileBasedArchitectures.pdf tbr 和tbdr ...