title: How to set shortcut in vim for specific file name?
body: <p>In my .vimrc I have</p>
  
  <pre><code>" Rspec Shortcuts
  nnoremap &lt;leader&gt;t :!clear; bundle exec rspec % --fail-fast&lt;cr&gt;
  
  " Minitest Shortcuts
  nnoremap &lt;leader&gt;t :!clear; bundle exec ruby -w -Itest %&lt;cr&gt;
  </code></pre>
  
  <p>I want to enable these shortcuts to be conditioned with the file name.</p>
  
  <p>I have tried setting the condition like this:</p>
  
  <pre><code>if @% =~ '*_spec.rb'
    nnoremap &lt;leader&gt;t :!clear; bundle exec rspec % --fail-fast&lt;cr&gt;
  endif
  
  if @% =~ '*_test.rb'
    nnoremap &lt;leader&gt;t :!clear; bundle exec ruby -w -Itest %&lt;cr&gt;
  endif
  </code></pre>
  
  <p>But it did not work.
  Without the conditions the shortcuts are working of course.</p>