Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html5/Javascript: Emmet / code snippets #197

Open
hhstore opened this issue Aug 5, 2020 · 2 comments
Open

Html5/Javascript: Emmet / code snippets #197

hhstore opened this issue Aug 5, 2020 · 2 comments

Comments

@hhstore
Copy link
Owner

hhstore commented Aug 5, 2020

related:

#37 : pycharm 设置
#112 : cheat sheet
#259 : Android Studio 设置

@hhstore
Copy link
Owner Author

hhstore commented Aug 5, 2020

前端代码: Emmet 简写 Snippet

  • 手写 HTML, 真 TM 是个体力活. 受不了.
  • Emmet: 是个通用的 code snippet 标准.
    • 各种 IDE/编辑器(webstorm/vscode)都支持.
    • 内置各种前端代码段的简写方法.

Emmet:

示例规则:

  • 各种快捷简写: 极大提升手写 HTML 的速度.
  • 缩写: div+div>p>span+em^bq + Tab 键
<div></div>
<div>
    <p><span></span><em></em></p>
    <blockquote></blockquote>
</div>
  • 缩写: div+div>p>span+em^^bq + Tab 键
<div></div>
<div>
    <p><span></span><em></em></p>
</div>
<blockquote></blockquote>

IDE 自定义 snippet:

Webstorm 自定义 snippet 模板:

@hhstore
Copy link
Owner Author

hhstore commented Aug 5, 2020

WebStorm:

  • 关于写前端代码的自定义配置.

live template: 自定义 snippet 模板

github 一些模板:

添加 ES6 箭头函数 简写

  • 打开设置, 找到 live template, 然后找到 JavaScript 分类, 右侧 +, 添加一个新的模板.

  • 添加新的 模板:

image

  • type1: es6 箭头函数模板: fn (缩写词)
($MODULE_VAR$) => {
    $END$
}

image

  • type2: 单行箭头函数: fn2(缩写词). 注意: 不要勾选Reformat 选项, 会干扰格式.
($MODULE_VAR$) => $MODULE_VAR$

image

  • 保存之后, 在编辑器中, 输入: fn, 然后 Tab 键, 就会自动补全 es6 箭头函数.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant