VS code 自定義快捷輸入
位置
ctrl+shift+p
- 搜尋:
snippets
- 輸入型別: 比如
html
、javascript
引數說明
prefix
:使用程式碼段的快捷入口body
:需要設定的程式碼放在這裡,字串間換行的話使用\r\n換行符隔開.如果值裡包含特殊字元需要進行轉義,多行程式碼以”,”分隔(在引號後面寫逗號)$0
:定義最終游標位置$1
:定義第一次游標位置,按tab鍵可進行快速切換, 還可以有$2
,$3
,$4
,$5
…description
:程式碼段描述,在使用智慧感知時的描述
常用字元說明
\\
反斜槓\a
警告\b
退格符\f
換頁符\n
換行符\r
回車符\t
Tab 符\v
垂直 Tab 符\u
使用數字指定的Unicode 字元, 如\u2000
\x
使用十六進位制數指定的Unicode 字元, 如\xc8
\0
空值
HTML
//自定義
"phone": {
"prefix": "ph",
"body": [
"<!DOCTYPE html>",
"<html lang='en'>",
"<head>",
" <meta charset='UTF-8'>",
" <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>",
" <meta name='viewport' content='width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0'/>",
" <title>Titile</title>",
"</head>",
"<body>",
"<script type='text/javascript'>",
" $('html').css({fontSize:$(window).width()/375*100 + 'px'});",
" $('body').css({minHeight:$(window).height()});",
"</script>",
"</body>",
"</html>"
],
"description": "script"
},
"script": {
"prefix": "sc",
"body": [
"<script type='text/javascript' src='$1'></script>"
],
"description": "script"
}
JavaScript
// 自定義
"function": {
"prefix": "fn",
"body": [
"function$1($2) {\r\n\t$3\r\n}"
],
"description": "function(){}"
},
"console.log": {
"prefix": "co",
"body": [
"console.log ($1);"
],
"description": "console.log()"
},
"alert": {
"prefix": "al",
"body": [
"alert ($1);"
],
"description": "alert()"
},
"class": {
"prefix": "cl",
"body": [
"$('.$1')"
],
"description": "class"
},
"id": {
"prefix": "id",
"body": [
"$('#$1')"
],
"description": "id"
},
"on": {
"prefix": "on",
"body": [
"on ('click',function () {\r\n\t$1\r\n})"
],
"description": "on"
},
"for": {
"prefix": "fo",
"body": [
"for (let i=0; i<$1; i++) {\r\n\t$2\r\n}"
],
"description": "for"
},
"if": {
"prefix": "ifif",
"body": [
"if ($1) {\r\n\t$2\r\n}"
],
"description": "if"
},
"ifElse": {
"prefix": "ifel",
"body": [
"if ($1) {\r\n\t$2\r\n} else {\r\n\t$3\r\n}"
],
"description": "ifElse"
},
"ajax": {
"prefix": "aj",
"body": [
// "$.ajax({\r\n\turl:$1,\r\n\tdata:{\r\n\t\t$2\r\n\t},\r\n\ttype:'post',\r\n\tdataType:'JSON',\r\n\tsuccess:function (res) {\r\n\t\t$3\r\n\t}\r\n})"
"$.ajax({",
" url: $1,",
" data:{",
" $2",
" },",
" type: 'post',",
" dataType: 'JSON',",
" success:function (res) {",
" $3",
" }",
"})"
],
"description": "ajax"
},
"axios": {
"prefix": "ax",
"body": [
"axios.$1(__PROJECTPATH__ + `$2`, {",
" $3",
"})",
".then(function (response) {",
" console.log(response);",
"})",
".catch(function (error) {",
" console.log(error);",
"});",
],
"description": "axios"
}
Vue
注: 元件/例項的書寫順序參照 Vue 風格指南
// 自定義(移動端)
"vue": {
"prefix": "vu",
"body": [
"<!-- $1 -->",
"<template>",
" <div>",
" $2",
" </div>",
"</template>",
"",
"<script>",
" export default {",
" name: '',",
" components: {",
" ",
" },",
" props: {",
" ",
" },",
" data() {",
" return {",
" ",
" }",
" },",
" computed: {",
" ",
" },",
" watch: {",
" ",
" },",
" created() {",
" ",
" },",
" methods: {",
" ",
" },",
" }",
"</script>",
"",
"<style scoped lang='less'>",
" ",
"</style>"
],
"description": "Vue templet"
}
相關文章
- VSCode自定義快捷輸入VSCode
- flutter 自定義驗證碼輸入框實現 verification_code_customFlutter
- 超實用VS Code快捷鍵
- VS code Windows和MacOS快捷鍵WindowsMac
- VS Code 快捷開啟PHP頁面PHP
- VS Code - Vim 外掛自動切換輸入法
- vscode 自定義快捷鍵VSCode
- word自定義快捷鍵
- 自定義 Linux 快捷命令Linux
- 給谷歌輸入法增添自定義片語,提高輸入效率谷歌
- CAD自定義快捷鍵命令
- IDEA自定義設定快捷鍵輸出你想要的語句!Idea
- 要點3:輸入函式對比與自定義輸入方式函式
- VS Code 如何設定大小寫轉換快捷鍵
- Shader從入門到跑路:自定義紋理輸入
- Android自定義方形驗證碼輸入框Android
- Sketch怎麼自定義快捷鍵
- vs 2017 vs code
- Android View篇之自定義驗證碼輸入框AndroidView
- iOS開發使用UIKeyInput自定義密碼輸入框iOSUI密碼
- React Native 自定義鍵盤之輸入車牌號React Native
- Artisan 自定義輸出格式
- VS2019 自定義專案模板
- C4D常用快捷鍵與自定義快捷鍵分享
- MacBook Pro如何自定義設定快捷鍵?Mac
- rubymine設定自定義快捷程式碼片段
- 開發者需掌握的超實用VS Code for Windows快捷鍵Windows
- Flutter 自定義輸入框Selection選單和選擇器Flutter
- WPF 自定義文字框輸入法 IME 跟隨游標
- Vue自定義指令實現input限制輸入正整數Vue
- Hadoop自定義輸出排序方式Hadoop排序
- Angular 自定義結構化指令,如何傳入多個輸入引數Angular
- VS2010自定義模版全過程
- spring boot學習(5): 程式exit code自定義Spring Boot
- 自定義 ocelot 中介軟體輸出自定義錯誤資訊
- VS Code 快捷方式所指的專案“Code.exe”已經更改或移動,因此該快捷方式無法正常工作
- vs 快捷鍵
- 如何自定義 CI/CD 配置檔案中的輸入引數?