日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ClangFormat代码格式化

發(fā)布時間:2024/10/12 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ClangFormat代码格式化 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

下載地址:https://github.com/travisjeffery/ClangFormat-Xcode

?

配合Xcode自帶的格式化操作,就很不錯了

選中內(nèi)容組合操作:

第一步:ClangFormat(control+U)

第二步:XcodeFormat(control+I)

?

選中文件組合操作:

第一步:ClangFormat(control+shift+U)

第二步:XcodeFormat(control+A,control+I)

?

修改ClangFormat.xcodeproj工程里的TRVSClangFormat.m文件的內(nèi)容,實現(xiàn)快捷鍵功能(control+U和control+shift+U):

1 - (void)addActioningMenuItemsToFormatMenu { 2 NSMenuItem *formatActiveFileItem = [[NSMenuItem alloc] 3 initWithTitle:NSLocalizedString(@"Format File in Focus", nil) 4 action:@selector(formatActiveFile) 5 keyEquivalent:@""]; 6 [formatActiveFileItem setTarget:self.formatter]; 7 [self.formatMenu addItem:formatActiveFileItem]; 8 NSMenuItem *formatSelectedCharacters = [[NSMenuItem alloc] 9 initWithTitle:NSLocalizedString(@"Format Selected Text", nil) 10 action:@selector(formatSelectedCharacters) 11 keyEquivalent:@"u"]; //modified by Kenmu 12 [formatSelectedCharacters setKeyEquivalentModifierMask:NSControlKeyMask]; //created by Kenmu, in order to use shortcut key to access it. 13 [formatSelectedCharacters setTarget:self.formatter]; 14 [self.formatMenu addItem:formatSelectedCharacters]; 15 NSMenuItem *formatSelectedFilesItem = [[NSMenuItem alloc] 16 initWithTitle:NSLocalizedString(@"Format Selected Files", nil) 17 action:@selector(formatSelectedFiles) 18 keyEquivalent:@"u"]; //modified by Kenmu 19 [formatSelectedFilesItem setKeyEquivalentModifierMask:NSControlKeyMask | NSShiftKeyMask]; //created by, in order to use shortcut key to access it. Kenmu 20 [formatSelectedFilesItem setTarget:self.formatter]; 21 [self.formatMenu addItem:formatSelectedFilesItem]; 22 }

?

跟VVDocumenter規(guī)范注釋生成器的安裝方式一樣:

下載開源工程在Xcode重新編譯運行會自動安裝此插件,重啟Xcode就可以使用了

?

PS:可以使用系統(tǒng)偏好設置中設置鍵盤里針對某應用程序的快捷鍵,如下操作:

?

插件設置:

?

使用方式:

?

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/huangjianwu/p/4562145.html

總結(jié)

以上是生活随笔為你收集整理的ClangFormat代码格式化的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。