文章詳情頁
javascript - 新建js文件時(shí)如何自動(dòng)地加上"use strict"?
瀏覽:182日期:2024-03-31 16:51:32
問題描述
setline(1,''use strict'')不行。
問題解答
回答1:使用自動(dòng)化構(gòu)建工具 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()'
這個(gè)方便以后為其他類型的文件添加相似的功能, 參見 Vim 新建文件時(shí)自動(dòng)添加文件頭
或者僅針對(duì)這個(gè)使用場(chǎng)景:
function! s:add_title_js() call setline(1,’use strict’) call append(line(’.’), ’’)endfunctionautocmd FileType javascript execute 'call s:add_title_js()'回答3:
用的什么編輯器?
標(biāo)簽:
JavaScript
相關(guān)文章:
1. python - 獲取到的數(shù)據(jù)生成新的mysql表2. javascript - js 對(duì)中文進(jìn)行MD5加密和python結(jié)果不一樣。3. mysql里的大表用mycat做水平拆分,是不是要先手動(dòng)分好,再配置mycat4. window下mysql中文亂碼怎么解決??5. sass - gem install compass 使用淘寶 Ruby 安裝失敗,出現(xiàn) 4046. python - (初學(xué)者)代碼運(yùn)行不起來,求指導(dǎo),謝謝!7. 為啥不用HBuilder?8. python - flask sqlalchemy signals 無法觸發(fā)9. python的文件讀寫問題?10. 為什么python中實(shí)例檢查推薦使用isinstance而不是type?
排行榜

熱門標(biāo)簽