For simplicity: just place the .vimrc
in the ~/
.
One can configure the relevant vim plugins by specifying in the ~/.vimrc
file. This is extremely helpful as one can just source this .vimrc file to customize the VIM text editor. Here I will go through the less obvious configuration commands.
I use the plug-in manager vim-plug.
-
The installation can be done entirely in .vimrc with the following code:
if empty(glob('~/.vim/autoload/plug.vim')) silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif
-
Quick start:
:PlugStatus
shows current plugins;:PlugInstall
installs the plugins as per specified in.vimrc
;:Plugclean
un-installs plugins deleted in.vimrc
-
Adding plug-ins go in between:
call plug#begin('~/.vim/plugged')
andcall plug#end()
-
Nerd Tree (Plug 'preservim/nerdtree')
Quick start: I have re-mapped the toggle command (:NerdTreeToggle
toctrl-f
. This toggles the menu on the side displaying the file structures of the current directory. -
Latex-suite for Vim (
vim-latex/vim-latex
).\ Quick start:- to compile-
\ll
; to open up pdf-\lv
. - help function:
:h latex-suite.txt
Important: For OS, I use the Skim Pdf reader:
let g:Tex_ViewRule_pdf = 'open -a Skim'
For Linux, I use Zathura:let g:Tex_ViewRule_pdf = 'zathura'
- to compile-
-
Ultisnip- Snippet Managers (
'SirVer/ultisnips'
)
Quick start: to configure specific snippets, launch:UltiSnipsEdit
when the relavent file (e.g..py
,.tex
) is opened. -
Vim-markdown preview(Plug 'JamshedVesuna/vim-markdown-preview')
Prerequisites: install grip (Github flavoured Markdown)
Quick Start: to launch markdown preview. -
Gruvbox theme (Plug 'morhetz/gruvbox'): Use gruvbox theme in vi.
- Ctags: Downloaded Exuberant ctags (see
:h ctags
for more information)
Quick start: In terminal, run 'ctags -R .' to generate tags. This generates a link across files on definitions. One can useCTRL-]
to jump to the declaration of a function in the source file.
-
The
Set
pattern: using:set
to control specfic functions:
Formula:set foo
: "enable the option (foo)set nofoo
: "disable itset foo!
: "toggle the optionset foo?
:"get option's current value
Examples
- Display line number:
:set number
;:set nonumber
to turn off.
- Enable spell check:
:setlocal spell spelllang=en_us
; to disable::set nospell
- Find a file:
:find myfile.extension
- Leave current session:
ctrl-z
; re-open at terminal:fg
- Re-use last visual select:
gv
- Copy to system clip board:
"*y
- Toggle case of character under cursor pr all visually-selected characters:
~
ctrl-O
to jump back to the previous (older) location.ctrl-I
(same as Tab) to jump forward to the next (newer) location.- Go to definition in same file:
gd