Skip to content

Instantly share code, notes, and snippets.

@thomasba
Created January 31, 2019 21:54
Show Gist options
  • Save thomasba/20150afa17dfdebc046fed61ace6c5af to your computer and use it in GitHub Desktop.
Save thomasba/20150afa17dfdebc046fed61ace6c5af to your computer and use it in GitHub Desktop.
" Map keys to toggle functions
function! MapToggle(key, opt)
let cmd = ':set '.a:opt.'! \| set '.a:opt."?\<CR>"
exec 'nnoremap '.a:key.' '.cmd
exec 'inoremap '.a:key." \<C-O>".cmd
endfunction
command! -nargs=+ MapToggle call MapToggle(<f-args>)
MapToggle <F7> hlsearch
MapToggle <F4> number
MapToggle <F5> spell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment