Skip to content

Instantly share code, notes, and snippets.

@marcotrosi
Last active November 29, 2015 20:18
Show Gist options
  • Save marcotrosi/3e13689d05a07b8297b8 to your computer and use it in GitHub Desktop.
Save marcotrosi/3e13689d05a07b8297b8 to your computer and use it in GitHub Desktop.
function! LaTeXMenu(modeprecmd)
let l:FontCmds = ["abort", "FontFamily", "FontSize"]
let l:c = 0
let l:c = confirm("LaTeX Menu","Font&Family\nFont&Size")
if l:c == 1
call FontFamily(a:modeprecmd)
endif
if l:c == 2
call FontSize(a:modeprecmd)
endif
endfunction
function! FontFamily(modeprecmd)
let l:FontFamilies = ["abort", "textbf", "textit", "textup", "textsl", "textsc", "textrm", "textsf", "texttt"]
let l:c = 0
let l:c = confirm("Font Family","text&bf\ntext&it\ntext&up\ntext&sl\ntexts&c\ntext&rm\ntexts&f\ntext&tt")
if l:c != 0
exe 'call TeXEmbrace("' . a:modeprecmd . '", "' . l:FontFamilies[l:c] . '")'
endif
endfunction
function! FontSize(modeprecmd)
let l:FontSizes = ["abort", "tiny", "scriptsize", "footnotesize", "small", "large", "Large", "LARGE", "huge", "Huge", "HUGE"]
let l:c = 0
let l:c = confirm("Font Size","&tiny\ns&criptsize\n&footnotesize\n&small\n&large\nL&arge\nLA&RGE\n&huge\nHu&ge\nHUG&E", 3)
if l:c != 0
exe 'call TeXEmbrace("' . a:modeprecmd . '", "' . l:FontSizes[l:c] . '")'
endif
endfunction
function! TeXEmbrace(modeprecmd, texcmd)
exe "normal " . a:modeprecmd . "xi{}\<ESC>PF{i\\=a:texcmd\<CR>"
endfunction
nnoremap <leader>L :call LaTeXMenu("viw")<CR>
vnoremap <leader>L :call LaTeXMenu("gv")<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment