【问题标题】:How can I turn off automatic attribute quoting in Emmet-Vim?如何关闭 Emmet-Vim 中的自动属性引用?
【发布时间】:2016-11-05 13:07:37
【问题描述】:

默认情况下,当我使用属性扩展 html 标记时,属性的值会被引号括起来。

例如Route[component={Main}]-><Route component="{Main}"></Route>

然而,当我使用 React 时,我想必须指定我希望扩展版本何时有引号。在我给出的示例中,我想要这种行为:

Route[component={Main}]-><Route component={Main}></Route>

Emmet-Vim 可以吗?

【问题讨论】:

    标签: vim emmet


    【解决方案1】:

    根据文档:

    |g:user_emmet_settings| may be used to change attribute quote character

    所以只需将其设置为空(在 vimrc 中):

    let g:user_emmet_settings = {
      \    'html' : {
      \        'quote_char': ""
      \    }
      \}
    

    有关详细信息,请参阅第 3.4 节。 Emmet-vim Documentation 的引用字符

    P.S.如果您使用的是 jsx,只需将 'html' 替换为 'jsx'

    【讨论】:

    • 这解决了我提到的用例,但不幸的是,我造成的弊大于利。例如,我会失去类引用:Story.short -> <Story class=short>
    • 当然不需要任何特殊设置来处理jsx 文件。刚才在jsx 文件中测试Route[component={Main}]Story.short 并分别正确扩展为<Route component={Main}></Route><Story className="short"></Story>,第一个没有qoutes,第二个有qoutes。
    • 有趣!我所有的 React 文件都是 .js 文件...我想知道是否有办法获得相同的行为是 js 文件。
    • 添加到你的 .vimrclet g:user_emmet_settings = {'javascript': {'extends': 'jsx'}}
    • 所以添加到你的 .vimrc 中:let g:user_emmet_settings = {'javascript.jsx': {'extends': 'jsx'}} 一切都应该没问题。看来您使用 vim-jsx 插件并将javascript文件的文件类型设置为javascript.jsx
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-08
    • 2016-06-14
    • 2016-04-21
    • 1970-01-01
    • 2013-01-10
    • 2016-04-10
    • 2011-09-10
    相关资源
    最近更新 更多