How to bookmark code in XCode 4?

2020-05-16 13:22发布

I couldn't find a way to put a bookmark inside the code in XCode 4. I know about the #pragma mark thing but it's not what I'm looking for. What I need is something that I can put and remove with a mouse click and navigate amongst with next and previous, like in VS.

Is there anything that I'm missing?

8条回答
2楼-- · 2020-05-16 13:51

You can install an Xcode plugin called "XBookmark".

This plugin provide features below :

  • Toggle Bookmark
  • Show Bookmarks
  • Next Bookmark
  • Previous Bookmark

How to install XBookmark:

  1. Install Alcatraz.
  2. Search XBookmark from Window->Package Manager and click Install.
  3. Restart Xcode.

Now, you can see menus about bookmarks in the Edit Menu.

PS : This plugin is open source.

查看更多
Anthone
3楼-- · 2020-05-16 13:55

Another option, if anyone is still interested. The following directives will both produce a compiler warning that you can use as a bookmark:

#pragma message "<# message #>"

or

#warning <# message #>

If you want to place bookmarks using your mouse: create a code snippet with one of the 2 directives above. Drag & drop it to the line in your source file that you want bookmarked.

Navigate to next/previous with: Cmd-' and Cmd-Shift-'

查看更多
来,给爷笑一个
4楼-- · 2020-05-16 14:01

Write below comment in your source file that you want bookmarked.

 //<##>

And you can navigate to next / previous with: '^/' or '^?'

  1. <##> means "placeholder of code snippet"
  2. ^/ means "jump to next placeholder"
  3. ^? means "jump to previous placeholder"

thanks

查看更多
孤傲高冷的网名
5楼-- · 2020-05-16 14:07

Bookmarks seem to have gone the way of the dinosaur in Xcode 4. This wouldn't have been so bad had the jump-to-bookmark popup above the editor in previous versions not also disappeared. The best replacement currently seems to be to use breakpoints (disabled individually, of course) and navigate with the Breakpoint Navigator.

Shortcut to breakpoints is Cmmd + 7. Once there use arrow keys

File a bug report at http://bugreporter.apple.com if you feel something like this should be brought back.

查看更多
可以哭但决不认输i
6楼-- · 2020-05-16 14:10

Like npellow's answer to this question of mine, appCode by JetBrains has also made this possible. So, this may be another reason to use appCode instead of Xcode4, except that it won't be free later in time.

查看更多
一纸荒年 Trace。
7楼-- · 2020-05-16 14:11

In Xcode 4.4, if you leave a comment with this format:

// TODO: Your text here

it will be added as a listing in the jump bar alongside the list of methods in your current file, and then you can jump straight to that comment from that menu.

查看更多
登录 后发表回答