title: VIM : How to map command according to buffer type?
body: <p>I know my title is not that descriptive/clear so let me explain.</p>
  
  <p>Yesterday I can across <code>Vimgrep and copen</code> so I added the below line in <code>.vimrc</code></p>
  
  <pre><code>nnoremap &lt;silent&gt; ,/ :execute 'vimgrep /'.@/.'/g %'&lt;CR&gt;:copen&lt;CR&gt;
  </code></pre>
  
  <p>What it does is open a <code>quickfix list</code> for the <code>searched(highlighted)</code> word in vim.</p>
  
  <p>Now when you press <code>Enter&lt;CR&gt;</code> in quickfix list it takes you to a corresponding line in the main Vim Window.</p>
  
  <p>Now, the problem I am facing is I have mapped my <code>&lt;CR</code> like <code>map &lt;CR&gt; o&lt;Esc&gt;</code> which creates a new line just below the current line.</p>
  
  <p>So, as you can see there is a conflict b/w the two. So, what I am trying is to come up with a vim function like</p>
  
  <p><em>Pseudo Code</em></p>
  
  <pre><code>function IfNotInsideQuickFix()
      if buffer != QuickFix
          then map &lt;CR&gt; o&lt;Esc&gt;
      elif buffer == QuickFix
           Normal behaviour
  
  Call function
  </code></pre>
  
  <p>Here is the output of <code>:buffers</code> </p>
  
  <pre><code>:buffers
    1 #a   "test.cs"                      line 0
    2 %a-  "[Quickfix List]"              line 1
  Press ENTER or type command to continue
  </code></pre>
  
  <p>I have no experience in writing vim functions. So, can someone please guide me to it.</p>
  
  <p>PS: I know that I can change my Vim mapping to create a new line but I want to learn how to do it via Vim function</p>