<p><spanclass="sc"><abbrtitle="Trop long; pas lu">tlpl</abbr>: </span> Comment utiliser vim comme une IDE très efficace</p>
<p>In <ahref="../../../../Scratch/en/blog/Learn-Vim-Progressively/">Learn Vim Progressively</a> I’ve show how Vim is great for editing text, and navigating in the same file (buffer). In this short article you’ll see how I use Vim as an IDE. Mainly by using some great plugins.</p>
<p>☞ Note I have two parts in my <code>.vimrc</code>. The first part contains the list of all my plugins. The second part contains the personal preferences I setted for each plugin. I’ll separate each part by <code>...</code> in the code.</p>
<p>Before anything, you should protect your eyes using a readable and low contrast colorscheme.</p>
<p>For this I use <ahref="http://ethanschoonover.com/solarized">solarized dark</a>. To add it, you only have to write this in your <code>~/.vimrc</code> file:</p>
<p>One of the most important hidden skills in programming is the ability to search and find files in your projects.</p>
<p>The majority of people use something like <code>NERDTree</code>. This is the classical left column with a tree of files of your project. <em>I stopped to use this</em>. And you should probably too.</p>
<p>I switched to <em>unite</em>. No left column lost. Faster to find files. Mainly it works like Spotlight on OS X.</p>
<p>First install <ahref="https://github.com/ggreer/the_silver_searcher"><code>ag</code> (the silver search)</a>. If you don’t know <code>ack</code> or <code>ag</code> your life is going to be upgraded. This is a simple but essential tool. It is mostly a <code>grep</code> on steroids.</p>
<preclass="vim"><code>" Unite
" depend on vimproc
" ------------- VERY IMPORTANT ------------
" you have to go to .vim/plugin/vimproc.vim and do a ./make
" -----------------------------------------
Plug 'Shougo/vimproc.vim'
Plug 'Shougo/unite.vim'
...
let g:unite_source_history_yank_enable = 1
try
let g:unite_source_rec_async_command='ag --nocolor --nogroup -g ""'
<p>Now type space twice. A list of files appears. Start to type some letters of the file you are searching for. Select it, type return and bingo the file opens in a new horizontal split.</p>
<p>Don’t forget to add a space after the <code>:Ag</code>.</p>
<p>These are two of the most powerful shortcut for working in a project. using <code>°</code> which is nicely positioned on my <code>azerty</code> keyboard. You should use a key close to <code>*</code>.</p>
<p>So what <code>°</code> is doing? It reads the string under the cursor and search for it in all files. Really useful to search where a function is used.</p>
<p>If you type <code><space>/</code> followed by a string, it will search for all occurrences of this string in the project files.</p>
<p>So with this you should already be able to navigate between files very easily.</p>
<h3id="basic-auto-completion-c-n-c-p">Basic auto completion: <code>C-n</code>&<code>C-p</code></h3>
<p>Vim has a basic auto completion system. The shortcuts are <code>C-n</code> and <code>C-p</code> while you are in insert mode. This is generally good enough in most cases. For example when I open a file not in my configured languages.</p>
<h2id="haskell">Haskell</h2>
<p>My current Haskell programming environment is great!</p>
<p>Each time I save a file, I get a comment pointing to my errors or proposing me how to improve my code.</p>
<p>So here we go:</p>
<blockquote>
<p>☞ Don’t forget to install <code>ghc-mod</code> with: <code>cabal install ghc-mod</code></p>
</blockquote>
<preclass="vim"><code>" ---------- VERY IMPORTANT -----------
<p>My main language at work is Clojure. And my current vim environment is quite good. I lack the automatic integration to <code>lein-kibit</code> thought. If I have the courage I might do it myself one day. But due to the very long startup time of clojure, I doubt I’ll be able to make a useful vim plugin.</p>
<p>So mainly you’ll have real rainbow-parenthesis (the default values are broken for solarized).</p>
<p>I used the vim <code>paredit</code> plugin before. But it is too restrictive. Now I use <code>sexp</code> which feel more coherent with the spirit of vim.</p>
<p>Working with Clojure will becomre quite smoother. You can eval any part of your code, you must launch a Clojure REPL manually in another terminal thought.</p>
<h2id="last-words">Last words</h2>
<p>I hope it will be useful.</p>
<p>Last but not least, if you want to use my vim configuration you can get it here:</p>