ClangFormat代码格式化
下载地址:https://github.com/travisjeffery/ClangFormat-Xcode
配合Xcode自带的格式化操作,就很不错了
选中内容组合操作:
第一步:ClangFormat(control+U)
第二步:XcodeFormat(control+I)
选中文件组合操作:
第一步:ClangFormat(control+shift+U)
第二步:XcodeFormat(control+A,control+I)
修改ClangFormat.xcodeproj工程里的TRVSClangFormat.m文件的内容,实现快捷键功能(control+U和control+shift+U):
- (void)addActioningMenuItemsToFormatMenu {
NSMenuItem *formatActiveFileItem = [[NSMenuItem alloc]
initWithTitle:NSLocalizedString(@"Format File in Focus", nil)
action:@selector(formatActiveFile)
keyEquivalent:@""];
[formatActiveFileItem setTarget:self.formatter];
[self.formatMenu addItem:formatActiveFileItem];
NSMenuItem *formatSelectedCharacters = [[NSMenuItem alloc]
initWithTitle:NSLocalizedString(@"Format Selected Text", nil)
action:@selector(formatSelectedCharacters)
keyEquivalent:@"u"]; //modified by Kenmu
[formatSelectedCharacters setKeyEquivalentModifierMask:NSControlKeyMask]; //created by Kenmu, in order to use shortcut key to access it.
[formatSelectedCharacters setTarget:self.formatter];
[self.formatMenu addItem:formatSelectedCharacters];
NSMenuItem *formatSelectedFilesItem = [[NSMenuItem alloc]
initWithTitle:NSLocalizedString(@"Format Selected Files", nil)
action:@selector(formatSelectedFiles)
keyEquivalent:@"u"]; //modified by Kenmu
[formatSelectedFilesItem setKeyEquivalentModifierMask:NSControlKeyMask | NSShiftKeyMask]; //created by, in order to use shortcut key to access it. Kenmu
[formatSelectedFilesItem setTarget:self.formatter];
[self.formatMenu addItem:formatSelectedFilesItem];
}
跟VVDocumenter规范注释生成器的安装方式一样:
下载开源工程在Xcode重新编译运行会自动安装此插件,重启Xcode就可以使用了
PS:可以使用系统偏好设置中设置键盘里针对某应用程序的快捷键,如下操作:

插件设置:

使用方式:


ClangFormat代码格式化的更多相关文章
- vim代码格式化插件clang-format
title: vim代码格式化插件clang-format date: 2017-12-12 20:28:26 tags: vim categories: 开发工具 安装vim-clang-forma ...
- 超详细的Xcode代码格式化教程,可自定义样式。
超详细的Xcode代码格式化教程,可自定义样式. 为什么要格式化代码 当团队内有多人开发的时候,每个人写的代码格式都有自己的喜好,也可能会忙着写代码而忽略了格式的问题.在之前,我们可能会写完代码后,再 ...
- ROS知识(21)----ROS C++代码格式化
这里提供两种方法. 第一种方法:clang_format 1.安装clang format sudo apt-get install -y clang-format-3.6 2.从github的ros ...
- 测试clang-format的格式化效果
我自己写的业余框架已告一段落,主体功能已完成,剩下的就是优化.第一个要优化的,就是代码格式.我一直是用编辑器写代码的,从之前的UltraEdit到notepad++到sublime text,再到现在 ...
- [No00007B]DreamweaverCC 的CSS代码格式化
Dreamweaver自带的代码格式化功能. 1.步骤:命令 -> 应用源格式. 2.你可以选择你的偏好.特别是css代码,有些人喜欢每个属性单独一行,有些人喜欢把所有属性写在同一行.步骤:编辑 ...
- code blocks 如何实现一键代码格式化
问题:code blocks 如何实现一键代码格式化 解答:直接右键,选择format use ASstyle
- 使用AStyle进行代码格式化
转自:http://www.cnblogs.com/JerryTian/archive/2012/09/20/AStyle.html 在日常的编码当中,大家经常要遵照一些设计规范,如命名规则.代码格式 ...
- iOS开发-xCode代码格式化xAlign
xCode默认是可以进行代码格式化的,能满足基础开发需求,如果想要个性一些代码对齐方式宏对齐,等号对齐,属性对齐,xAlign就提供了以上三种功能,参考文中效果~ 基础效果 等号对齐: 属性对齐: 宏 ...
- MyEclipse中防止代码格式化时出现换行的情况的设置
编辑完成代码,用MyEclipse的代码格式化后,本来不长的代码也被自动转成了多行.虽然自动换行以后在编辑器中一眼就能看到全部的代码,但是可读性却大打折扣,避免出现这种情况的办法是: 1.Java代码 ...
随机推荐
- C语言字符串格式化显示
符号 作用 ────────────────────────── %d 十进制有符号整数 %i 输 ...
- iOS - UITableView加载网络图片 cell适应图片高度
使用xib创建自定制cell 显示图片 创建一个继承UITableViewCell的类 勾选xib 如下是xib创建图 xib 向.h拖拽一个关联线 .h .m 2.代码创建(使用三方适配 ...
- [转]Oracle trunc()函数的用法
原文地址:http://www.cnblogs.com/gengaixue/archive/2012/11/21/2781037.html 1.TRUNC(for dates) TRUNC函数为指定元 ...
- Python对字典(directory)按key和value排序
distance = {9149: 0, 9150: 26, 9151: 24, 9152: 24, 9153: 24, 9154: 27, 9155: 25, 9156: 30, 9158: 20, ...
- CSS综合小练习
CSS选择器学了不少了,现在来实战一下. <!DOCTYPE html> <html lang="en"> <head> <meta ch ...
- Spring WebSocket初探1 (Spring WebSocket入门教程)<转>
See more: Spring WebSocket reference整个例子属于WiseMenuFrameWork的一部分,可以将整个项目Clone下来,如果朋友们有需求,我可以整理一个独立的de ...
- 淘宝开放平台获取沙箱token
沙箱环境的文档都是错的,直接使用以下地址: 输入淘宝测试账号: sandbox_c_1 密码: taobao1234 https://login.tbsandbox.com/member/log ...
- 1px的border
css中是这样写的: div{ border-bottom: 1px solid #dfe5e4; } 但在手机上,像素比不为 1 ,由于 webview 的灰度渲染, border 一般会显示为 2 ...
- filter和map的区别
filter和map初一看很像 都是filter(func,iterable) map(func,iterable) 实际情况是filter函数:filter()为已知的序列的每个元素调用给定的布尔函 ...
- java 生成指定区间随机数
int randNumber =rand.nextInt(MAX - MIN + 1) + MIN; // randNumber 将被赋值为一个 MIN 和 MAX 范围内的随机数