Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8677293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:25:15+00:00 2026-06-12T20:25:15+00:00

Please note: I have been through this link Jump to CSS definition when editing

  • 0

Please note: I have been through this link Jump to CSS definition when editing HTML in VIM, but it couldn’t help me.

I am looking to jump to the CSS definition or for that matter a javascript function from the html file. I would love to hit a key combo below the word to jump to its definition, not just the file in which the definition resides.

I currently need to search the word in opened buffers and then reach to all the search results in the required buffer. It is very time consuming.

Please help me with this very regular requirement.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:25:16+00:00Added an answer on June 12, 2026 at 8:25 pm

    This quick and dirty function seems to do the trick for *.html -> *.css:

    function! JumpToCSS()
      let id_pos = searchpos("id", "nb", line('.'))[1]
      let class_pos = searchpos("class", "nb", line('.'))[1]
    
      if class_pos > 0 || id_pos > 0
        if class_pos < id_pos
          execute ":vim '#".expand('<cword>')."' **/*.css"
        elseif class_pos > id_pos
          execute ":vim '.".expand('<cword>')."' **/*.css"
        endif
      endif
    endfunction
    
    nnoremap <F9> :call JumpToCSS()<CR>
    
    • test.html

      <html>
        <body>
          <div class="foo" id="bar">lorem</div>
          <div id="bar" class="foo">ipsum</div>
          <div id="bar">dolor</div>
          <div class="foo">sit</div>
        </body>
      </html>
      
    • foo/foo.css

      .foo {
        background-color: red;
      }
      
    • bar/bar.css

      #bar {
        border-color: gold;
      }
      

    With the cursor on any foo or bar attribute value in test.html, hitting <F9> jumps to the right definition in the right file. The function could be modified to open the target file in a split, search only the linked stylesheets… or be completely ridiculed and destroyed by ZyX ;-).

    edit

    A few additional pointers:

    • :help iskeyword for this function to work with dash-joined names
    • :help expand()
    • :help searchpos() and :help search() for the meanings of the arguments
    • :help starstar for the use of the ** wildcard
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please note that I have been through the existing links on this topic and
Please note that I have already been through similar questions and their answers here
I have been searching for this online, but I can't seem to find something
(Please note that I have seen a similar question on StackOverflow recently, however I
PLEASE NOTE, I have found a work around which actually works out better for
Please note this application will never be running on a server system. I am
Please note that I'm not asking how but why. And I don't know if
[Please note that this is a different question from the already answered How to
Please note: This is a question about the Eclipse plugin Subversive , and not
Please note this is not a question about online/hosted SVN services. I am working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.