Home Download Buy Blog Forum Support

Bookmarks

Bookmarks

Postby handycam on Tue Jul 03, 2012 11:42 pm

I noticed this as a feature of Coda 2:

Add Custom Bookmarks to the Navigator
It’s fine and dandy to have your named HTML elements show up in the navigator, but what if you could add any line to it, like a bookmark? You totally can. In any syntax mode, just type a comment and prefix its contents with a !, like so:
/* !Page start */
Or, single-line-comment style:
// !Bookmark
It’ll then show up as a bookmark in the Code Navigator


http://www.panic.com/blog/2012/07/top-20-secrets-of-coda-2/

This is exactly what I have been asking about in Sublime. Is this possible, to show up in Goto Symbol?
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: Bookmarks

Postby jps on Wed Jul 04, 2012 12:44 am

You can do it with a .tmPreferences file like this:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Comment Markers</string>
    <key>scope</key>
    <string>source comment</string>
    <key>settings</key>
    <dict>
        <key>showInSymbolList</key>
        <integer>1</integer>
        <key>symbolTransformation</key>
        <string>s/^[^!]*!([^\n]*).*/$1/g</string>
    </dict>
</dict>
</plist>
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Bookmarks

Postby Lag on Wed Jul 04, 2012 11:45 pm

Can you just drop this into your prefs? I'm a noob with Sublime, but I've been using coda for awhile now... and I love being able to have a bookmarks pane that lets me jump to sections of my code quickly (like the first poster was stating).


jps wrote:You can do it with a .tmPreferences file like this:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Comment Markers</string>
    <key>scope</key>
    <string>source comment</string>
    <key>settings</key>
    <dict>
        <key>showInSymbolList</key>
        <integer>1</integer>
        <key>symbolTransformation</key>
        <string>s/^[^!]*!([^\n]*).*/$1/g</string>
    </dict>
</dict>
</plist>
Lag
 
Posts: 1
Joined: Tue Jul 03, 2012 11:53 pm

Re: Bookmarks

Postby handycam on Thu Jul 05, 2012 4:17 pm

jps wrote:You can do it with a .tmPreferences file like this:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Comment Markers</string>
    <key>scope</key>
    <string>source comment</string>
    <key>settings</key>
    <dict>
        <key>showInSymbolList</key>
        <integer>1</integer>
        <key>symbolTransformation</key>
        <string>s/^[^!]*!([^\n]*).*/$1/g</string>
    </dict>
</dict>
</plist>


Pretty cool, but that just shows ALL my comments, not just the ones I marked with a !
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: Bookmarks

Postby C0D312 on Thu Jul 05, 2012 5:09 pm

Then just change the regex string to whatever you want.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Bookmarks

Postby quodlibet on Thu Jul 05, 2012 6:58 pm

Hi,

I took a stab at this.

Save the following to Packages/User/Comment Bang.tmPreferences (or whatever):

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Comment Bang</string>
    <key>scope</key>
    <string>comment</string>
    <key>settings</key>
    <dict>
        <key>showInSymbolList</key>
        <integer>1</integer>
        <key>symbolTransformation</key>
        <string>
           s/^\S+\s*//g      # strip opening punctuation + spacing
           s/^[^!].*//g      # remove all comments that DON'T begin with a bang
           s/^!\s*//g         # strip bang and subsequent spaces (if any)
           s/^(.*?)\n.*/$1/g   # keep only 1st line (in case of multiline comment)
        </string>
    </dict>
    <key>uuid</key>
    <string>7fdae8f0-c6c7-11e1-9b21-0800200c9a66</string>
</dict>
</plist>


I'm pretty to new to writing regular expressions, so this is probably not the most efficient way to do it, but it works so long as you put at least one space or tab before the bang.

So:
# !this works
#!this doesn't

BUGS:
+ Doesn't work in CSS, although it works for other syntaxes with C-style comments (/* xxx */). Need to investigate.

TODO:
+ Strip common punctuation from end of single comments (such as, -->)
+ Re-write so that you don't need to space before the bang (while still ignoring HTML punctuation)
quodlibet
 
Posts: 531
Joined: Sat Jun 18, 2011 5:53 pm

Re: Bookmarks

Postby bobrocke on Sun Dec 30, 2012 7:56 pm

quodlibet wrote:Hi,

I took a stab at this.

Save the following to Packages/User/Comment Bang.tmPreferences (or whatever):

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Comment Bang</string>
    <key>scope</key>
    <string>comment</string>
    <key>settings</key>
    <dict>
        <key>showInSymbolList</key>
        <integer>1</integer>
        <key>symbolTransformation</key>
        <string>
           s/^\S+\s*//g      # strip opening punctuation + spacing
           s/^[^!].*//g      # remove all comments that DON'T begin with a bang
           s/^!\s*//g         # strip bang and subsequent spaces (if any)
           s/^(.*?)\n.*/$1/g   # keep only 1st line (in case of multiline comment)
        </string>
    </dict>
    <key>uuid</key>
    <string>7fdae8f0-c6c7-11e1-9b21-0800200c9a66</string>
</dict>
</plist>


I'm pretty to new to writing regular expressions, so this is probably not the most efficient way to do it, but it works so long as you put at least one space or tab before the bang.

So:
# !this works
#!this doesn't

BUGS:
+ Doesn't work in CSS, although it works for other syntaxes with C-style comments (/* xxx */). Need to investigate.

TODO:
+ Strip common punctuation from end of single comments (such as, -->)
+ Re-write so that you don't need to space before the bang (while still ignoring HTML punctuation)


Thanks, guys, for this thread. It gave me the clues I needed to get past my mental roadblock.

In the process, I fixed a few of the "bugs" listed above.

At least with my copy of Sublime Text, I have a CSS package that was interfering. It had a file 'Symbol List Group.tmPreferences' that I removed to solve the conflict.

To strip the punctuation from the line end, I added:

s/\W*$//g

as the last statement.
Bob
-----
Bob Rockefeller
Richmond Hill, GA
"I'm growing older, but not up!"
www.bobrockefeller.com
bobrocke
 
Posts: 14
Joined: Sun Dec 02, 2012 2:20 pm

Re: Bookmarks

Postby pier on Mon Dec 31, 2012 4:18 pm

Isn't this a bit irrelevant?

Sublime has already a bookmarks system...
pier
 
Posts: 92
Joined: Fri Jun 15, 2012 2:47 am

Re: Bookmarks

Postby bobrocke on Tue Jan 01, 2013 10:40 pm

pier wrote:Isn't this a bit irrelevant?

Sublime has already a bookmarks system...


A poor system. They don't get named and they don't get saved (unless you add a plug-in).
Bob
-----
Bob Rockefeller
Richmond Hill, GA
"I'm growing older, but not up!"
www.bobrockefeller.com
bobrocke
 
Posts: 14
Joined: Sun Dec 02, 2012 2:20 pm

Re: Bookmarks

Postby highend on Mon Jan 07, 2013 4:54 am

Really nice, and much more intuitive to jump to "named" bookmarks :)
highend
 
Posts: 94
Joined: Fri Jan 20, 2012 2:47 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 28 guests