javascript - How to automatically add "use strict" when creating a new js file?
伊谢尔伦
伊谢尔伦 2017-06-06 09:54:23
0
3
757

setline(1,"\"use strict\"")No.

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(3)
大家讲道理

Use the automated build tool gulp to write ES6 directly after configuration

滿天的星座
function! s:add_title()
  if &filetype == 'javascript'
    call setline(1, 'use strict')
    call append(line('.'), '')
  endif
endfunction

autocmd BufNewFile *.js execute "call s:add_title()"

This is convenient for adding similar functions to other types of files in the future. See Vim to automatically add file headers when creating new files

Or just for this usage scenario:

function! s:add_title_js()
    call setline(1,'use strict')
    call append(line('.'), '')
endfunction

autocmd FileType javascript execute "call s:add_title_js()"
曾经蜡笔没有小新

What editor are you using?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!