This is a quick run-through of how I set up my development environment in vim:
mkdir -p ~/.vim/autoload ~/.vim/bundle; \ curl -Sso ~/.vim/autoload/pathogen.vim \ https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
Add the following to ~/.vimrc:
execute pathogen#infect() syntax on filetype plugin indent on
cd ~/.vim/bundle git clone https://github.com/scrooloose/syntastic.git
Then quit vim and used :Helptags to check installs so far have worked.
opam switch 4.01.0dev+trunk opam update opam upgrade opam install merlin
Add the following to ~/.vimrc
:set rtp+=~/.opam/4.01.0dev+trunk/share/ocamlmerlin/vim :set rtp+=~/.opam/4.01.0dev+trunk/share/ocamlmerlin/vimbufsync let g:syntastic_ocaml_checkers=['merlin']
:SyntasticInfo will return a list of syntax checkers available to Syntastic, check that this now includes merlin
Install OCP Indent
opam install ocp-indent
Add the following to ~/.vimrc
autocmd FileType ocaml source /home/heidi-ann/.opam/4.01.0dev+trunk/share/typerex/ocp-indent/ocp-indent.vim
Learning to escape VIM
I have a confession, the first I launched vim I could not even work out how to quit it so I took the lazy way out and just closed the terminal. This put me right off vim for quite a while. Now its time to really try to learn it.
Vim has two modes: insert and normal, when you launch vim it will go straight into normal mode, from normal mode type i to switch to insert mode and then press ESC to return back to normal mode.
Normal mode basics
You can delete the character under the cursor using x and using :w to save. To cut the current line use dd, this will delete the text on the current line and also delete the line itself, the cursor will move to the next line, which is now where the original line was. To copy the current line use yy. Now to paste the recently cut line, use p to insert the text onto the line below where the cursor currently is or P to insert text before cursor.
Instead of the arrow keys, you can make use of hjkl to move the cursor, but personal I prefer to use the arrow keys
Entering Insert mode
So far we have entered insert mode using i, there are some alternative ways to enter insert mode, which allow you to move to insert mode and perform a useful operation in one key stoke, some of the alternative methods to enter insert mode are:
Moving around normal mode
As well as using the arrow keys (or hjkl) to navigate around normal mode, there are plenty of useful extra shortcuts for navigating around. 0 jumps to first character in the row and $ goes to the last character in the row. ^ jumps to the first non-blank character of a line and g_ goes to the last non_blank character of line.
To search for a particular work or character, use / and enter search term. This will move the cursor to the next occurrence of the search term after the cursor, so to search for the first occurrence of a term in a file, put the cursor at the start of the file and then use / to search for the term.
To jump to the start of the next word use w and to go to end of this word use e, when a word is composed of letters and underscores only, if you want to word to include special characters use W and E instead
Text editor basics
u is used to undo and Crtl-r to redo. To open a file use :e , :w to save, :saveas , to save and quit. :q! to quit without saving. . will repeat last command and N