<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: thekingofspain</title>
    <description>The latest articles on Forem by thekingofspain (@thekingofspain).</description>
    <link>https://forem.com/thekingofspain</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3835729%2F65cd27f7-8ebd-47a7-b1c2-fc716ff581bf.png</url>
      <title>Forem: thekingofspain</title>
      <link>https://forem.com/thekingofspain</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/thekingofspain"/>
    <language>en</language>
    <item>
      <title>CLI coding Agent Newline Hell: Mapping Shift+Enter to Ctrl+Enter</title>
      <dc:creator>thekingofspain</dc:creator>
      <pubDate>Thu, 26 Mar 2026 18:33:28 +0000</pubDate>
      <link>https://forem.com/thekingofspain/cli-coding-agent-newline-hell-mapping-shiftenter-to-ctrlenter-1ce3</link>
      <guid>https://forem.com/thekingofspain/cli-coding-agent-newline-hell-mapping-shiftenter-to-ctrlenter-1ce3</guid>
      <description>&lt;h2&gt;
  
  
  HELL = &lt;code&gt;Shift+Enter&lt;/code&gt; =&amp;gt; &lt;code&gt;Enter&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Your writing a long prompt in you CLI coding agent tooling and you want to create a blank line for a new point, code code block, etc., and you accidently type &lt;code&gt;Shift+Enter&lt;/code&gt;...&lt;/p&gt;






&lt;h2&gt;
  
  
  The &lt;em&gt;Terminal&lt;/em&gt; did it, The &lt;em&gt;Terminal&lt;/em&gt; pressed &lt;code&gt;Enter&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;If you've started using AI coding assistants (like aider, gpt-me, or open-code) directly in your terminal, you've likely run into a frustrating muscle memory clash around &lt;code&gt;Shift+Enter&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In web chats, Teams, Slack, and VSCode Code Assistants, &lt;code&gt;Shift+Enter&lt;/code&gt; gives you a &lt;code&gt;New Line&lt;/code&gt;, while &lt;code&gt;Enter&lt;/code&gt; sends the message. However, most CLI coding agent tools follow the &lt;code&gt;Terminal&lt;/code&gt; keyboard standards/behaviors (if you are reading this, the &lt;code&gt;Terminal&lt;/code&gt; standards were more than likely written before you were born: ASCII(1963), and VT100(1978) aka boomer old school)&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key Command&lt;/th&gt;
&lt;th&gt;Key Operation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Enter&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Submit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Shift+Enter&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Submit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Ctrl+Enter&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;New Line&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Often the CLI coding agent will remap the key command based on its editor setting exposed by its &lt;code&gt;/editor&lt;/code&gt; command. But if you're like me and want the freedom of using the editor without the CLI coding assistant file noise, &lt;strong&gt;there is no real way in the CLI coding assistant to change the &lt;code&gt;Shift+Enter&lt;/code&gt; key command's key operation&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;There is a way to fix this problem globally on Linux (including WSL) using &lt;code&gt;keyd&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  keyd
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;keyd&lt;/code&gt; is a powerful key remapping daemon for Linux that intercepts keys and key sequences and remaps them to other keys and key sequences.&lt;/p&gt;

&lt;p&gt;We will configure &lt;code&gt;keyd&lt;/code&gt; to run at startup using &lt;code&gt;systemd&lt;/code&gt; to map the &lt;code&gt;Shift+Enter&lt;/code&gt; key command to the &lt;code&gt;Ctrl+Enter&lt;/code&gt; key command.&lt;/p&gt;




&lt;h3&gt;
  
  
  Steps
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Step 1 - &lt;code&gt;systemd&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;If you already have &lt;code&gt;systemd&lt;/code&gt; installed in your environment, jump to Step 2.&lt;/p&gt;

&lt;p&gt;To verify if &lt;code&gt;systemd&lt;/code&gt; is installed and running on your Linux instance, you can use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;which systemctl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;which systemctl
&lt;span class="go"&gt;/usr/sbin/systemctl
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Installation of &lt;code&gt;systemd&lt;/code&gt; is beyond this post and is Linux distro-specific. If you are running WSL, &lt;code&gt;systemd&lt;/code&gt; is configured in your &lt;code&gt;/etc/wsl.conf&lt;/code&gt; file:&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;code&gt;/etc/wsl.conf&lt;/code&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[boot]&lt;/span&gt;
&lt;span class="py"&gt;systemd&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  Step 2 - &lt;code&gt;keyd&lt;/code&gt; installation and configuration
&lt;/h4&gt;

&lt;h5&gt;
  
  
  &lt;code&gt;keyd&lt;/code&gt; installation
&lt;/h5&gt;

&lt;p&gt;Install the &lt;code&gt;keyd&lt;/code&gt; daemon using the package manager of your Linux distribution. For Arch Linux this is &lt;code&gt;pacman&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;pacman &lt;span class="nt"&gt;-Syu&lt;/span&gt; keyd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Substitute with your distribution's package manager: &lt;code&gt;apt&lt;/code&gt;, &lt;code&gt;yum&lt;/code&gt;, &lt;code&gt;emerge&lt;/code&gt;, etc.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;code&gt;keyd&lt;/code&gt; configuration
&lt;/h5&gt;

&lt;p&gt;With &lt;code&gt;keyd&lt;/code&gt; installed, you need to configure it. Edit the &lt;code&gt;/etc/keyd/default.conf&lt;/code&gt; file as admin in your favorite editor:&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;code&gt;/etc/keyd/default.conf&lt;/code&gt;
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[main]&lt;/span&gt;
&lt;span class="c"&gt;# Explicitly map physical shifts to the shift layer
&lt;/span&gt;&lt;span class="py"&gt;leftshift&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;layer(shift)&lt;/span&gt;
&lt;span class="py"&gt;rightshift&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;layer(shift)&lt;/span&gt;

&lt;span class="nn"&gt;[shift]&lt;/span&gt;
&lt;span class="c"&gt;# When shift is held, Enter sends Control+Enter instead
&lt;/span&gt;&lt;span class="py"&gt;enter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;C-enter&lt;/span&gt;
&lt;span class="py"&gt;kpenter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;C-enter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  Step 3 - Enable and start the &lt;code&gt;keyd&lt;/code&gt; service
&lt;/h4&gt;

&lt;p&gt;To enable the key remapping, run the following command:&lt;/p&gt;

&lt;h5&gt;
  
  
  Execute: &lt;code&gt;systemctl enable&lt;/code&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; &lt;span class="nt"&gt;--now&lt;/span&gt; keyd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Result
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; &lt;span class="nt"&gt;--now&lt;/span&gt; keyd
&lt;span class="go"&gt;Created symlink '/etc/systemd/system/multi-user.target.wants/keyd.service' → '/usr/lib/systemd/system/keyd.service'.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To verify there are no errors you can run the following:&lt;/p&gt;

&lt;h5&gt;
  
  
  Execute: &lt;code&gt;systemctl status&lt;/code&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status keyd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Result
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status keyd
&lt;span class="go"&gt;● keyd.service - key remapping daemon
&lt;/span&gt;&lt;span class="gp"&gt;     Loaded: loaded (/usr/lib/systemd/system/keyd.service;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;enabled&lt;span class="p"&gt;;&lt;/span&gt; preset: disabled&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="gp"&gt;     Active: active (running) since Thu 2026-03-26 10:58:09 CDT;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;1h 5min ago
&lt;span class="go"&gt; Invocation: 34ce0111ca5b4fbaa26742195cd99602
   Main PID: 218399 (keyd)
      Tasks: 1 (limit: 13704)
     Memory: 19.3M (peak: 19.8M)
        CPU: 37ms
     CGroup: /system.slice/keyd.service
             └─218399 /usr/bin/keyd
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These &lt;code&gt;keyd&lt;/code&gt; mappings take effect immediately, letting you enjoy both &lt;code&gt;Shift+Enter&lt;/code&gt; and &lt;code&gt;Ctrl+Enter&lt;/code&gt; in your AI coding assistant.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;keyd&lt;/code&gt; service can be disabled by running the following:&lt;/p&gt;

&lt;h4&gt;
  
  
  Execute: &lt;code&gt;systemctl disable&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl disable &lt;span class="nt"&gt;--now&lt;/span&gt; keyd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Result
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl disable &lt;span class="nt"&gt;--now&lt;/span&gt; keyd
&lt;span class="go"&gt;Removed '/etc/systemd/system/multi-user.target.wants/keyd.service'.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>hell</category>
      <category>ai</category>
      <category>newline</category>
      <category>enter</category>
    </item>
  </channel>
</rss>
