文章詳情頁
javascript - 新建js文件時如何自動地加上"use strict"?
瀏覽:252日期:2024-03-31 16:51:32
問題描述
setline(1,''use strict'')不行。
問題解答
回答1:使用自動化構建工具 gulp 配置好后可以直接寫 ES6
回答2:function! s:add_title() if &filetype == ’javascript’ call setline(1, ’use strict’) call append(line(’.’), ’’) endifendfunctionautocmd BufNewFile *.js execute 'call s:add_title()'
這個方便以后為其他類型的文件添加相似的功能, 參見 Vim 新建文件時自動添加文件頭
或者僅針對這個使用場景:
function! s:add_title_js() call setline(1,’use strict’) call append(line(’.’), ’’)endfunctionautocmd FileType javascript execute 'call s:add_title_js()'回答3:
用的什么編輯器?
標簽:
JavaScript
相關文章:
1. 對mysql某個字段監控的功能2. showpassword里的this 是什么意思?代表哪個元素3. html - vue項目中用到了elementUI問題4. JavaScript事件5. python - 為什么正常輸出中文沒有亂碼,zip函數之后出現中文編程unicode編碼的問題,我是遍歷輸出的啊。6. python - 使用readlines()方法讀取文件內容后,再用for循環遍歷文件與變量匹配時出現疑難?7. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能8. javascript - js中向下取整9. javascript - HTML字符串排版10. html5 - ElementUI table中el-table-column怎么設置百分比顯示。
排行榜
