Xcode Mark 类似于 emacs
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1002821/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode Mark similar to emacs
提问by cdespinosa
Is it possible to bookmark a line in Xcode similar to the "mark" functionality in emacs? Also is there a shortcut used I can use to jump to a line number? My source code is becoming long and hard to navigate.
是否可以在 Xcode 中为类似于 emacs 中的“标记”功能的行添加书签?还有我可以用来跳转到行号的快捷方式吗?我的源代码变得很长且难以导航。
回答by Alex Rozanski
Yes; if you place the text caret on the line that you want to bookmark and select Edit > Add to Bookmarks
(or ?D) you can add that line to the bookmarks in your project. You can then access these bookmarks from the Bookmarks
item in the Groups & Files
pane.
是的; 如果将文本插入符号放在要添加书签的行上并选择Edit > Add to Bookmarks
(或 ?D),则可以将该行添加到项目中的书签中。然后,您可以从窗格中的Bookmarks
项目访问这些书签Groups & Files
。
To go to a certain line, choose Edit > Go to Line...
from the menu (or ?L), and type in the line number you want to navigate to.
要转到某一行,请Edit > Go to Line...
从菜单(或 ?L)中选择,然后输入要导航到的行号。
I would also recommend that you use the #pragma mark
directive to help you navigate around in source files. It takes the format:
我还建议您使用该#pragma mark
指令来帮助您在源文件中导航。它采用以下格式:
#pragma mark <Label>
And will show up in the functions popup menu at the top of your source file; it makes it much easier to navigate around your code by grouping together common functions, improving the overall structure and readability of your code.
并将显示在源文件顶部的功能弹出菜单中;通过将常用功能组合在一起,可以更轻松地浏览代码,从而改善代码的整体结构和可读性。
回答by cdespinosa
You can also use the "mark" key sequence, control-@ or control-space, then you can use Delete to Mark (control-W), Select to Mark (control-X control-M), and Swap With Mark (control-X control-X). These emacs-like key bindings are supported in all Cocoa text views in Mac OS X, and you can customize the keybindings for Xcode in Xcode > Preferences > Key Bindings > Text Key Bindings.
您也可以使用“标记”键序列,control-@ 或 control-space,然后您可以使用删除标记(control-W)、选择标记(control-X control-M)和与标记交换(控制-X 控制-X)。Mac OS X 中的所有 Cocoa 文本视图都支持这些类似 emacs 的键绑定,您可以在 Xcode > Preferences > Key Bindings > Text Key Bindings 中为 Xcode 自定义键绑定。
回答by Brian Postow
You can bookmark an individual line in a file: in your .emacs file
您可以为文件中的单个行添加书签:在您的 .emacs 文件中
(global-set-key "\C-cb" 'bookmark-map)
sets it up, so:
设置它,所以:
control-c b m sets a bookmark (you can name it whatever you want.)
control-c bm 设置书签(您可以随意命名。)
control-c b j jumps to a bookmark (it asks which bookmark you want)
control-c bj 跳转到一个书签(它询问你想要哪个书签)
Also:
还:
(global-set-key [f1] 'goto-line)
sets F1 to ask for a line number and jump to that file
设置 F1 以询问行号并跳转到该文件