Skip to content

MahbubAlam231/vim-for-latex

Repository files navigation

vim-for-latex

My personalization of vim for mainly LaTeX. Here uploaded are,

  • My .vimrc;
  • My keybindings, snippets and abbreviations for LaTeX;
    • KeyBindings for writing math sets, Greek alphabets, math notations easily and fast;
    • Snippets for math sets, Greek alphabets, math environments;
    • General word abbreviations (using tpope/vim-abolish) and math abbreviations.
  • My templates for LaTeX;
    • A 'universal' latex template (tex.template).
  • A folding technique which is a mixture of LaTeX-Suite, Latex-Box and vimtex folding method. This a modification of petobens folding technique which can be found here and here. This folding technique uses foldmethod=marker and foldmarker=F{O{L{D,F}O}L}D.

Guide to install VIM and vim-for-latex

Download MahbubAlam231/vim-for-latex form GitHub.

You should consider swapping escape and caps key on your device, it makes it more convenient to press escape key. For Linux you can do this from system settings or by adding the line setxkbmap -option "caps:swapescape" at the end of your .bashrc, this will swap escape and caps key on your computer once you open VIM. To make this change permanent you can put the same line at the end of your ~/.profile file, this will swap escape and caps key every time you turn on your computer.

For Linux

  • Install VIM from command line using sudo apt install vim-gtk3;
  • Install vim-plug following installation guide;
  • Put .vimrc in your home directory;
  • Put Abbreviations, after, KeyBindings, spell and UltiSnips in ~/.vim;
  • Open .vimrc using VIM (it might throw some errors, but enter anyway), and run :PlugInstall;
  • Put LaTeX/templates in ~/.vim/bundle/vim-templates/;
  • Put LaTeX/tex in ~/.vim/plugged/vimtex/ftplugin/.

For macOS (not very sure about it btw)

  • Install VIM using homebrew;
  • Install vim-plug (or Vundle) following installation guide;
  • Put .vimrc in /Users/(your_pc_name);
  • Replace ~/.vim by /Users/(your_pc_name)/.vim in the above instructions for Linux;
  • There are some lines (after the 530th line) inside .vimrc file as well that contains ~/.vim, make similar changes there as well.

Learning the mappings

Read .vimrc, TeXKeyBindings.vim, NumbersPeacefully.vim, UnmapKeyBindings.vim, GeneralAbbreviations.vim, MathAbbreviations.vim and tex.snippets to learn about the mappings. NumbersPeacefully.vim and UnmapKeyBindings.vim are there to disable certain parts of TeXKeyBindings.vim.

The mappings are designed to be easy to remember, just like vim commands. As you go over these mappings I hope you will find that these are time-saving and easy-to-perform mappings.

For me these mappings simplify writing .tex files, and also many other types of files as well.

For basic vim tips you can watch the following videos-

For any query about vimscripts go to :help from inside vim. You can also look at the book Learn Vimscripts the Hard Way by Steve Losh.