Home Download Buy Blog Forum Support

Goto-CSS-Declaration (ST2 and ST3) - UPDATE: v0.3

Goto-CSS-Declaration (ST2 and ST3) - UPDATE: v0.3

Postby rmaksim on Mon Jan 02, 2012 6:29 pm

v0.3

https://sublime.wbond.net/packages/Goto-CSS-Declaration
https://github.com/rmaksim/Sublime-Text-2-Goto-CSS-Declaration

Goto CSS declaration in an open \*.css (.less, .sass, .other) file from other file (\*.html, \*.js, \*.other_extantion)

Image

Example
.html
Code: Select all
    <div id="box" class="box"></div>
                          ^
                          |-cursor
.js
Code: Select all
    $(".box").click(...);
         ^
         |-cursor

Pressing the key `super+right` or `super+left` go to the first CSS declaration of `box` (.class or #id => .box or #box), in this example the id `#box`
Code: Select all
    #box .box-shadow {
        background: url(../img/box.jpg);
        }
    #box-shadow .box-shadow-1 {
        box-shadow: 0 0 5px #ff0;
        }
        .box__inner {
            box-shadow: 0 0 5px #f00;
            }

and if then press (in CSS file) `super+right` goes to the next CSS declaration of `box`,
in this example the class `.box-shadow`,
- and next => `#box-shadow`,
- and next => `.box-shadow-1`,
- and next => `.box__inner`

also you can press (in CSS file) `super+left` and goes to the previous CSS declaration of `box`.

Default (Linux).sublime-keymap
Code: Select all
    super + right
    super + left

Default (Windows).sublime-keymap
Code: Select all
    super + .
    super + ,

support for .SASS and .LESS (and .other from goto_css_declaration.sublime-settings)
Code: Select all
    {
        "css_files": [".css", ".sass", ".less"]
    }
Last edited by rmaksim on Thu Nov 14, 2013 8:38 am, edited 13 times in total.
rmaksim
 
Posts: 59
Joined: Sat Jul 02, 2011 7:31 pm

Re: Goto-CSS-Declaration

Postby nobleach on Mon Jan 02, 2012 8:42 pm

Love it! I might extend it to work with SCSS files in Rails.... Time may tell me otherwise.
nobleach
 
Posts: 48
Joined: Thu Jun 23, 2011 4:14 pm

Re: Goto-CSS-Declaration

Postby chodorowicz on Mon Jan 02, 2012 10:55 pm

Very very very useful - many thanks!
chodorowicz
 
Posts: 18
Joined: Tue Oct 11, 2011 4:04 pm

Re: Goto-CSS-Declaration

Postby rooc on Thu Jan 05, 2012 5:57 pm

Excellent! But requires a bit of polishing, not just a simple search in css file. for example for class="box" it founds "box"-shadow, that's strange.
anyway - thanks!
rooc
 
Posts: 8
Joined: Sat Mar 19, 2011 12:30 pm

Re: Goto-CSS-Declaration

Postby iamntz on Thu Jan 05, 2012 7:07 pm

Wow, thanks. This is awesome!

I binded this into mousemap:
Code: Select all
{ "button": "button1", "count": 2, "modifiers": ["ctrl", "alt"], "command": "goto_css_declaration"},
{ "button": "button1", "count": 1,  "modifiers": ["ctrl", "alt"], "press_command": "drag_select" }


And works wonderful.

But yeah, i agree with rooc. It needs some polish because is jumping randomly sometimes.
iamntz
 
Posts: 920
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Goto-CSS-Declaration

Postby eikaramba on Thu Jan 05, 2012 10:11 pm

@nobleach mhmmm yeah scss support, i would love that ;)
eikaramba
 
Posts: 21
Joined: Thu Mar 10, 2011 1:06 am

Re: Goto-CSS-Declaration

Postby rmaksim on Fri Jan 06, 2012 8:28 am

rooc wrote:Excellent! But requires a bit of polishing, not just a simple search in css file. for example for class="box" it founds "box"-shadow, that's strange.
anyway - thanks!

I try to solve the problem with search.
rmaksim
 
Posts: 59
Joined: Sat Jul 02, 2011 7:31 pm

Re: Goto-CSS-Declaration

Postby rmaksim on Sat Jan 07, 2012 2:32 pm

UPDATE: v0.1.0

description & screencast see above viewtopic.php?f=5&t=4397#p19874

+ Added: go to the next/previous declaration in the CSS file
- Removed: F3 support

rooc wrote:for example for class="box" it founds "box"-shadow

fixed
rmaksim
 
Posts: 59
Joined: Sat Jul 02, 2011 7:31 pm

Re: Goto-CSS-Declaration

Postby VinnydaHorse on Fri Jan 13, 2012 4:42 am

Cannot for the life of me get this to work.

Super+any direction was resizing and relocating my window, so I changed the keys to ctrl+alt+left/right. (I checked and this is currently not in use by anything else)

Tried, still nothing. So I tried testing the code to see if it would run, and if it was just the keymapping.

Code: Select all
view.run_command("goto_css_declaration")


Tried the above and this is what I get back.

Code: Select all
>>> view.run_command("goto_css_declaration")
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 351, in run_
    return self.run(edit)
TypeError: run() takes exactly 3 arguments (2 given)


*EDIT

It's working now. Of course I figure it out after I ask the question. It was a simple matter of extra "{" before and after the keymap. Restarted and it's all good now.

I likes it.

I do not understand what is going on. Yes, I copied and pasted everything exactly as was posted, and only changed the key mappings. I still just cannot find any way to make this work.
VinnydaHorse
 
Posts: 1
Joined: Fri Jan 13, 2012 4:38 am

Re: Goto-CSS-Declaration

Postby rooc on Fri Jan 13, 2012 11:54 pm

VinnydaHorse wrote:I do not understand what is going on. Yes, I copied and pasted everything exactly as was posted, and only changed the key mappings. I still just cannot find any way to make this work.


I'm not sure if it is your case but corresponding css file should be opened in other tab

VinnydaHorse wrote:Super+any direction was resizing and relocating my window

yep, I also found this key mappings confusing because in windows they predefined for changing window behaviour
rooc
 
Posts: 8
Joined: Sat Mar 19, 2011 12:30 pm

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 4 guests