<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/assets/rss.xsl" type="text/xsl"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"

>
<channel>
	<title>Sacha Chua - tag - ace-jump</title>
	<atom:link href="https://sachachua.com/blog/tag/ace-jump/feed/index.xml" rel="self" type="application/rss+xml" />
	<atom:link href="https://sachachua.com/blog/tag/ace-jump" rel="alternate" type="text/html" />
	<link>https://sachachua.com/blog/tag/ace-jump/feed/index.xml</link>
	<description>Emacs, sketches, and life</description>
  
	<lastBuildDate>Mon, 06 Jul 2026 16:20:27 GMT</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>daily</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>11ty</generator>
  <item>
		<title>Emacs microhabit: Switching windows with windmove, ace-window, and ace-jump</title>
		<link>https://sachachua.com/blog/2015/01/emacs-microhabit-switching-windows-windmove-ace-window-ace-jump/</link>
		<dc:creator><![CDATA[Sacha Chua]]></dc:creator>
		<pubDate>Wed, 28 Jan 2015 13:00:00 GMT</pubDate>
    <category>emacs</category>
		<guid isPermaLink="false">https://sachachua.com/blog/?p=27863</guid>
		<description><![CDATA[<p>When I work with a large monitor, I often divide my Emacs frame (what most people call a window) into two or more windows (divisions within a frame). I like this more than dealing with multiple Emacs frames, even if I could spread those frames across multiple monitors. I find it easier to manage the windows using keyboard shortcuts than to manage the tiling and display of frames.</p>
<p>One of the Emacs micro-habits I&apos;m working on is getting better at switching between windows. When there are only two windows, <code>C-x o</code> (<code>other-window</code>) works just fine. However, when there are three or more, it can take a few repetitions of <code>C-x o</code> to get to where I want. I could get around that by binding <code>other-window</code> to <code>M-o</code> instead, replacing the default keymap for that. Or I could try to get the hang of other ways to move around.</p>
<p>Here&apos;s an 8-minute video showing <code>windmove</code>, <code>ace-window</code>, and <code>ace-jump</code>:</p>
<p><iframe loading="lazy" src="https://www.youtube.com/embed/nKCKuRuvAOw?list=UUlT2UAbC6j7TqOWurVhkuHQ" width="640" height="360" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
<p><a href="https://www.youtube.com/watch?v=nKCKuRuvAOw&amp;list=UUlT2UAbC6j7TqOWurVhkuHQ">https://www.youtube.com/watch?v=nKCKuRuvAOw&amp;list=UUlT2UAbC6j7TqOWurVhkuHQ</a></p>
<p>Windmove lets you move around with cursor keys, if you&#xA0;set up the appropriate keyboard shortcuts. Ace-window&#xA0;works like ace-jump. In addition, you can use C-u to swap windows and C-u C-u to delete windows. Ace-jump works across windows, so that&apos;s handy too.</p>
<p>Here&apos;s my&#xA0;relevant code snippet for Windmove. I changed this to use <code>define-key</code> instead of <code>bind-key</code>.</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span class="org-keyword">defvar</span> <span class="org-variable-name">sacha/windmove-map</span> (make-sparse-keymap))
(define-key sacha/windmove-map <span class="org-string">&quot;h&quot;</span> &apos;windmove-left)
(define-key sacha/windmove-map <span class="org-string">&quot;t&quot;</span> &apos;windmove-up)
(define-key sacha/windmove-map <span class="org-string">&quot;n&quot;</span> &apos;windmove-down)
(define-key sacha/windmove-map <span class="org-string">&quot;s&quot;</span> &apos;windmove-right)
(define-key sacha/windmove-map <span class="org-string">&quot;[left]&quot;</span> &apos;windmove-left)
(define-key sacha/windmove-map <span class="org-string">&quot;[up]&quot;</span> &apos;windmove-up)
(define-key sacha/windmove-map <span class="org-string">&quot;[down]&quot;</span> &apos;windmove-down)
(define-key sacha/windmove-map <span class="org-string">&quot;[right]&quot;</span> &apos;windmove-right)
(key-chord-define-global <span class="org-string">&quot;yy&quot;</span>     sacha/windmove-map)
</pre>
</div>
<p>Here&apos;s the cheat sheet I made for myself:</p>
<p><a href="https://sachachua.com/blog/wp-content/uploads/2015/01/2015-01-12-Emacs-microhabit-window-management-index-card-emacs.png"><img loading="lazy" class="alignnone size-medium wp-image-27865" src="https://sachachua.com/blog/wp-content/uploads/2015/01/2015-01-12-Emacs-microhabit-window-management-index-card-emacs-640x382.png" alt="2015-01-12 Emacs microhabit - window management &#45;&#45; index card #emacs" width="640" height="382" srcset="https://sachachua.com/blog/wp-content/uploads/2015/01/2015-01-12-Emacs-microhabit-window-management-index-card-emacs-640x382.png 640w, https://sachachua.com/blog/wp-content/uploads/2015/01/2015-01-12-Emacs-microhabit-window-management-index-card-emacs-280x167.png 280w, https://sachachua.com/blog/wp-content/uploads/2015/01/2015-01-12-Emacs-microhabit-window-management-index-card-emacs.png 1496w" sizes="(max-width: 640px) 100vw, 640px"></a></p>
<p><a href="https://sketches.sachachua.com/id/2015-01-12">2015-01-12 Emacs microhabit &#8211; window management &#x2013; index card #emacs</a></p>
<p>And here&apos;s a simpler reference that you can personalize with your own shortcuts:</p>
<p><img loading="lazy" class="alignnone size-medium wp-image-27864" src="https://sachachua.com/blog/wp-content/uploads/2015/01/2015-01-18-Emacs-microhabit-Switching-windows-index-card-emacs-microhabit-640x383.png" alt="2015-01-18 Emacs microhabit - Switching windows &#45;&#45; index card #emacs #microhabit" width="640" height="383" srcset="https://sachachua.com/blog/wp-content/uploads/2015/01/2015-01-18-Emacs-microhabit-Switching-windows-index-card-emacs-microhabit-640x383.png 640w, https://sachachua.com/blog/wp-content/uploads/2015/01/2015-01-18-Emacs-microhabit-Switching-windows-index-card-emacs-microhabit-280x168.png 280w, https://sachachua.com/blog/wp-content/uploads/2015/01/2015-01-18-Emacs-microhabit-Switching-windows-index-card-emacs-microhabit.png 1504w" sizes="(max-width: 640px) 100vw, 640px"></p>
<p><a href="https://sketches.sachachua.com/id/2015-01-18">2015-01-18 Emacs microhabit &#8211; Switching windows &#x2013; index card #emacs #microhabit</a></p>
<p>Naturally, after recording the video, I thought of a better way to manage my windows. I took&#xA0;advantage of the <code>def-repeat-command</code> that abo-abo posted on <a href="http://oremacs.com/2015/01/14/repeatable-commands/">(or emacs</a>&#xA0;so that I could repeat keybindings easily. I modified the function to accept <code>nil</code> as the first value if you don&apos;t want the keymap to run a command by default, and to use <code>kbd</code> for the keybinding definitions.</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">  (<span class="org-keyword">defun</span> <span class="org-function-name">sacha/def-rep-command</span> (alist)
    <span class="org-doc">&quot;Return a lambda that calls the first function of ALIST.</span>
<span class="org-doc">It sets the transient map to all functions of ALIST,</span>
<span class="org-doc">allowing you to repeat those functions as needed.&quot;</span>
    (lexical-let ((keymap (make-sparse-keymap))
                  (func (cdar alist)))
      (mapc (<span class="org-keyword">lambda</span> (x)
              (<span class="org-keyword">when</span> x
                (define-key keymap (kbd (car x)) (cdr x))))
            alist)
      (<span class="org-keyword">lambda</span> (arg)
        (interactive <span class="org-string">&quot;p&quot;</span>)
        (<span class="org-keyword">when</span> func
          (funcall func arg))
        (set-transient-map keymap t))))
</pre>
</div>
<p>Here&apos;s my new binding for <code>yy</code>. It lets me bounce on <code>y</code> to use <code>other-window</code> as normal, use the arrow keys to move between windows thanks to <code>windmove</code>, and use <code>ace-window</code> as well: <code>h</code> is the regular ace-window, <code>s</code> swaps, and <code>d</code> deletes.</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(key-chord-define-global <span class="org-string">&quot;yy&quot;</span>   
      (sacha/def-rep-command
       &apos;(nil
         (<span class="org-string">&quot;&lt;left&gt;&quot;</span> . windmove-left)
         (<span class="org-string">&quot;&lt;right&gt;&quot;</span> . windmove-right)
         (<span class="org-string">&quot;&lt;down&gt;&quot;</span> . windmove-down)
         (<span class="org-string">&quot;&lt;up&gt;&quot;</span> . windmove-up)
         (<span class="org-string">&quot;y&quot;</span> . other-window)
         (<span class="org-string">&quot;h&quot;</span> . ace-window)
         (<span class="org-string">&quot;s&quot;</span> . (<span class="org-keyword">lambda</span> () (interactive) (ace-window 4)))
         (<span class="org-string">&quot;d&quot;</span> . (<span class="org-keyword">lambda</span> () (interactive) (ace-window 16)))
         )))
</pre>
</div>
<p>Neat, eh?</p>

<p>You can <a href="https://sachachua.com/blog/2015/01/emacs-microhabit-switching-windows-windmove-ace-window-ace-jump/#comment">view 4 comments</a> or <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2015%2F01%2Femacs-microhabit-switching-windows-windmove-ace-window-ace-jump%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></description>
		</item>
	</channel>
</rss>