dotfiles

My personal dotfiles 💠️

commit a6abf80d9034175ad7c0e3d0fd254ad8612179d6
parent a1a4727ad3d0ad88184638c2c2fc666b081e5d0a
Author: Pablo <pablo-escobar@riseup.net>
Date:   Sat,  8 May 2021 13:21:58 -0300

Added a Vim macro to start LaTeX blocks

i.e. "\begin{foo} ... \end{foo}"

Diffstat:
M.config/nvim/init.vim | 18++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim
@@ -74,11 +74,25 @@ noremap <Right>   <Nop>
 noremap <S-Left>  <Nop>
 noremap <S-Right> <Nop>
 
-""" Language-specific stuff
+""" LaTeX-specific stuff
+
+" Begin a LaTeX block
+function! LaTeXBegin(blockname)
+  execute "normal! o\\begin{" . a:blockname . "}\n\\end{" . a:blockname . "}\n"
+  call feedkeys('kO')
+endfunction
+
+" Alias the LaTeXBegin function as a command
+au BufNewFile,BufRead *.tikz,*.tex command! -nargs=1 Begin call LaTeXBegin(<f-args>)
+
+" Map BB to a call to the Begin command
+au BufNewFile,BufRead *.tikz,*.tex nnoremap BB :Begin 
 
 " Highlight TiKz files as LaTeX
 au BufNewFile,BufRead *.tikz,*.tex        set ft=tex
 
+""" Language-specific stuff
+
 " Highlight .thtml files as HTML
 au BufNewFile,BufRead *.thtml             set ft=html
 
@@ -91,7 +105,7 @@ au BufNewFile,BufRead *.wat               set ft=wast
 " Correctly highlight fish scripts
 au BufNewFile,BufRead *.fish              set ft=fish
 
-" Read .pl files as Prolog (not Perl).
+" Read .pl files as Prolog (not Perl)
 au BufNewFile,BufRead *.pl                set ft=prolog
 
 " Read .m and .mathematica as Mathematica files