title: vim keyboard mapping problems on mac OSX
body: <h1>1.Env</h1>
  
  <p>vim7.3+zsh+iTerm2 on mavericks</p>
  
  <h1>2. Mapping Problem</h1>
  
  <p>Here are my problem list:</p>
  
  <ol>
  <li>My vim could not get some shortcuts: <code>&lt;C-q&gt;</code>,<code>&lt;C-s&gt;</code>,<code>&lt;A-Left|Right|..&gt;</code>,<code>&lt;D-char&gt;</code>.</li>
  <li>I could not map some special keys such as   <code>&lt;A-char&gt;</code> , <code>&lt;A-S-char&gt;</code> , <code>&lt;C-A-char&gt;</code>in mac.</li>
  </ol>
  
  <h2><code>&lt;C-q&gt;</code> and <code>&lt;C-s&gt;</code></h2>
  
  <p>In iTerm2, <code>&lt;C-q&gt;</code> will delete whole line, (and <code>&lt;C-s&gt;</code> will launch <code>Fwd-i-search</code>).<br>
  It doesn't behave like start/stop character , so that I thought this problem is nothing to do with <code>stty start</code> and <code>stty stop</code>.<br>
  <strong>But after I add this into <code>~/.zshrc</code>, I surprised to see that the map for <code>&lt;C-q&gt;</code> and <code>&lt;C-s&gt;</code> works well in Vim.</strong> At the same time it doesn't change the behavior of <code>&lt;C-q&gt;</code> and <code>&lt;C-s&gt;</code> in iTerm2(I don't know why).</p>
  
  <pre><code>stty start undef
  stty stop undef
  </code></pre>
  
  <h2><code>&lt;A-char&gt;</code> problem in mac</h2>
  
  <p>In mac, mappings for <code>&lt;A-char&gt;</code> won't directly work in mac.</p>
  
  <pre><code>:inoremap &lt;A-u&gt; type some string A-u
  :inoremap &lt;A-p&gt; type some string A-p
  :inoremap
  i  õ           * type some string A-u
  i  ð           * type some string A-p
  </code></pre>
  
  <p>As far as I know about <code>&lt;A-char&gt;</code> in mac, hit <code>&lt;A-u&gt;</code> will print nothing but with a sound alert. hit <code>&lt;A-p&gt;</code> will print <code>π</code>. I found that map for <code>π</code> works well.</p>
  
  <pre><code>:inoremap π type some string A-p
  </code></pre>
  
  <p>Is it possible to map <code>&lt;A-u&gt;</code> in vim?</p>
  
  <p>Another complex question, is it possible for <code>&lt;A-S-char&gt;</code>, <code>&lt;C-A-char&gt;</code></p>
  
  <pre><code>:map &lt;A-S-p&gt; not work
  :map ∏ works well(A-S-p will print `∏`)
  
  :map &lt;C-A-p&gt; not work
  :map &lt;C-π&gt; still not work
  
  :map &lt;C-S-p&gt; do work
  </code></pre>
  
  <p>Another complex question related above, is it possible mapping <code>&lt;C-A-char&gt;</code>?</p>
  
  <h2><code>&lt;A-Left|Right|UP|Down</code></h2>
  
  <p>In iTerm2 , hitting <code>&lt;A-Left|...</code> will result in(iTerm2 doesn't bind any shortcut for them.):</p>
  
  <pre><code>&lt;A-Up&gt; print 'A' with a sound alert.
  &lt;A-Down&gt; print 'B' with a sound alert.
  &lt;A-Left&gt; print 'D' with a sound alert.
  &lt;A-Down&gt; print 'C' with a sound alert.
  </code></pre>
  
  <p>In vim, <code>&lt;A-Left|...</code> is same as <code>&lt;Left&gt;&lt;Right&gt;&lt;Up&gt;&lt;Down&gt;</code> in insert mode , normal mode, visual mdoe  and Ex Mode, etc.</p>
  
  <h2><code>&lt;D-char&gt;</code></h2>
  
  <p>Some keys about <code>&lt;D-char&gt;</code> are iTerms's own hotkeys, such as :
  1. <code>&lt;D-q&gt;</code> will quit iTerm2
  1. <code>&lt;D-w&gt;</code> will close current tab in iTerm2</p>
  
  <p>On the other hand, the other keys such as <code>&lt;D-s&gt;</code> are not hotkey, and do not print any char in vim and terminal. Is it possible to map them in vim?</p>