setline(1,"\"use strict\"")
No.
大家讲道理2017-06-06 09:56:23
Use the automated build tool gulp to write ES6 directly after configuration
滿天的星座2017-06-06 09:56:23
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()"