• <small id='id4W3'></small><noframes id='id4W3'>

      <bdo id='id4W3'></bdo><ul id='id4W3'></ul>
    <tfoot id='id4W3'></tfoot>
    1. <i id='id4W3'><tr id='id4W3'><dt id='id4W3'><q id='id4W3'><span id='id4W3'><b id='id4W3'><form id='id4W3'><ins id='id4W3'></ins><ul id='id4W3'></ul><sub id='id4W3'></sub></form><legend id='id4W3'></legend><bdo id='id4W3'><pre id='id4W3'><center id='id4W3'></center></pre></bdo></b><th id='id4W3'></th></span></q></dt></tr></i><div id='id4W3'><tfoot id='id4W3'></tfoot><dl id='id4W3'><fieldset id='id4W3'></fieldset></dl></div>

        <legend id='id4W3'><style id='id4W3'><dir id='id4W3'><q id='id4W3'></q></dir></style></legend>

      1. 使用单次击键从 Vim 中的 HTML 文件跳转到 CSS 文件中的 CSS 选择器

        jump to CSS selector in a css file from the HTML file in Vim using a single keystroke(使用单次击键从 Vim 中的 HTML 文件跳转到 CSS 文件中的 CSS 选择器)
        <i id='alDbD'><tr id='alDbD'><dt id='alDbD'><q id='alDbD'><span id='alDbD'><b id='alDbD'><form id='alDbD'><ins id='alDbD'></ins><ul id='alDbD'></ul><sub id='alDbD'></sub></form><legend id='alDbD'></legend><bdo id='alDbD'><pre id='alDbD'><center id='alDbD'></center></pre></bdo></b><th id='alDbD'></th></span></q></dt></tr></i><div id='alDbD'><tfoot id='alDbD'></tfoot><dl id='alDbD'><fieldset id='alDbD'></fieldset></dl></div>
          <legend id='alDbD'><style id='alDbD'><dir id='alDbD'><q id='alDbD'></q></dir></style></legend>

          <small id='alDbD'></small><noframes id='alDbD'>

            <tbody id='alDbD'></tbody>

            • <tfoot id='alDbD'></tfoot>
                <bdo id='alDbD'></bdo><ul id='alDbD'></ul>

                  本文介绍了使用单次击键从 Vim 中的 HTML 文件跳转到 CSS 文件中的 CSS 选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  请注意:我已经通过此链接 跳转到在 VIM 中编辑 HTML 时的 CSS 定义,但对我没有帮助.

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

                  我希望跳转到 CSS 定义或 html 文件中的 javascript 函数.我很想点击单词下方的组合键来跳转到它的定义,而不仅仅是定义所在的文件.

                  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.

                  推荐答案

                  这个快速而肮脏的函数似乎对 *.html -> *.css 有用:

                  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;
                    }
                    

                  • 将光标放在 test.html 中的任意 foobar 属性值上,点击 <F9> 跳转到正确文件中的正确定义.可以修改该函数以拆分打开目标文件,仅搜索链接的样式表……或者被 ZyX 完全嘲笑和破坏;-).

                    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 ;-).

                    编辑

                    一些额外的指针:

                    • :help iskeyword 让这个函数使用破折号连接的名字
                    • :help expand()
                    • :help searchpos():help search() 了解参数的含义
                    • :help starstar 用于使用 ** 通配符
                    • :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

                    这篇关于使用单次击键从 Vim 中的 HTML 文件跳转到 CSS 文件中的 CSS 选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                  Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                  Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                  How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                  Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                  Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))

                    <tfoot id='wcKWZ'></tfoot>

                    <small id='wcKWZ'></small><noframes id='wcKWZ'>

                          <tbody id='wcKWZ'></tbody>

                        • <bdo id='wcKWZ'></bdo><ul id='wcKWZ'></ul>
                          <i id='wcKWZ'><tr id='wcKWZ'><dt id='wcKWZ'><q id='wcKWZ'><span id='wcKWZ'><b id='wcKWZ'><form id='wcKWZ'><ins id='wcKWZ'></ins><ul id='wcKWZ'></ul><sub id='wcKWZ'></sub></form><legend id='wcKWZ'></legend><bdo id='wcKWZ'><pre id='wcKWZ'><center id='wcKWZ'></center></pre></bdo></b><th id='wcKWZ'></th></span></q></dt></tr></i><div id='wcKWZ'><tfoot id='wcKWZ'></tfoot><dl id='wcKWZ'><fieldset id='wcKWZ'></fieldset></dl></div>

                            <legend id='wcKWZ'><style id='wcKWZ'><dir id='wcKWZ'><q id='wcKWZ'></q></dir></style></legend>