vimrc: add AppendModeline func

This commit is contained in:
surtur 2022-10-30 03:38:29 +01:00
parent c63faf67fc
commit aa31766bae
Signed by: wanderer
SSH Key Fingerprint: SHA256:MdCZyJ2sHLltrLBp0xQO0O1qTW9BT/xl5nXkDvhlMCI

@ -1243,6 +1243,18 @@ set exrc
set secure set secure
" Append modeline before first line in buffer.
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX
" files.
function! AppendModeline()
let l:modeline = printf(' vim: set ts=%d ft=%s fenc=%s ff=%s :',
\ &tabstop, &filetype, &fileencoding, &fileformat)
let l:modeline = substitute(&commentstring, '%s', l:modeline, '')
call append (line('^'), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>
function! AskQuit (msg, proposed_action) function! AskQuit (msg, proposed_action)
if confirm(a:msg, "&Quit?\n" . a:proposed_action) == 1 if confirm(a:msg, "&Quit?\n" . a:proposed_action) == 1
exit exit