title: Insert blank line above or below the current line in Vim
body: <p>I recently surprised myself wanting to insert blank lines above or below the current line either in normal or insert mode. </p>
  
  <p>I usually add blank lines to my code for better reading or to properly separate blocks of code. </p>
  
  <p>To do this I am using the following in my .vimrc: </p>
  
  <pre><code>" Add empty line above and below the current line
  nnoremap &lt;silent&gt; &lt;C-K&gt; mP:pu! _&lt;cr&gt;:']+1&lt;cr&gt;`P
  inoremap &lt;silent&gt; &lt;C-K&gt; &lt;esc&gt;mP:pu! _&lt;cr&gt;:']+1&lt;cr&gt;`Pa
  nnoremap &lt;silent&gt; &lt;C-J&gt; mP:pu _&lt;cr&gt;:'[-1&lt;cr&gt;`Pa
  nnoremap &lt;silent&gt; &lt;C-J&gt; &lt;esc&gt;mP:pu _&lt;cr&gt;:'[-1&lt;cr&gt;`Pa      
  </code></pre>
  
  <p>The only ugly thing with these mapping is I'm using the marker P just to go back to the previous cursor position. I tried to use `` instead but it doesn't do what I expected. </p>
  
  <p>Perhaps there is a slightly better solution otherwise this snippet works quite well for me. </p>
  
  <p>I am slowly adding new mapping in my .vimrc. I noticed the <code>&lt;C-[a-z]&gt;</code> combinaisons are mostly free and the existing ones are pretty useless (i.e. <code>&lt;C-Q&gt;</code>, <code>&lt;C-H&gt;</code>, <code>&lt;C-M&gt;</code>…). Then I decided to bind them to new useful mapping: </p>
  
  <pre><code>&lt;C-N&gt; New file
  &lt;C-S&gt; Save (:update!)
  &lt;C-P&gt; CtrlP mixed mode
  &lt;C-S-P&gt; CtrlPCmdPalette
  &lt;C-B&gt; CtrlP buffers mode
  &lt;C-D&gt; &lt;C-C&gt;ciw
  …
  </code></pre>