# "join" without extra whitespace?

**URL:** <https://discuss.kakoune.com/t/join-without-extra-whitespace/225>\
**Category:** Help\
**Created:** [December 8, 2018, 11:12am UTC](https://discuss.kakoune.com/t/join-without-extra-whitespace/225 "2018-12-08T11:12:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbrains](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/jbrains/32/61_2.png) [@jbrains](https://discuss.kakoune.com/u/jbrains)\
**Post date:** [December 8, 2018, 11:12am UTC](https://discuss.kakoune.com/t/join-without-extra-whitespace/225/1 "2018-12-08T11:12:28Z")

</div>

Hi, folks. When I use “join” (alt+j or alt+J) to join lines, I notice that Kakoune inserts a space before the incoming line. I don’t expect it to do that. I mostly delete that space.

1. Do other people expect the current behavior? If so, then why do you prefer it?
2. Assuming that “join” _ought_ not to insert that extra space, how easily can one fix it? If it seems easy, then I’d consider trying to contribute that myself.

Thank you.

Example:

* * *

invoice:

Put the cursor on the beginning of the line with “—”, then press alt+j.

I expect this line:  
—invoice:

Instead, I see this line:  
— invoice:

---

<div class="post-metadata">

**Author:** ![eraserhd](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/eraserhd/32/15_2.png) [@eraserhd](https://discuss.kakoune.com/u/eraserhd)\
**Post date:** [December 8, 2018, 1:49pm UTC](https://discuss.kakoune.com/t/join-without-extra-whitespace/225/2 "2018-12-08T13:49:10Z")

</div>

Hi JB!!

I know I often use the space. For example: joining lines when reflowing markdown, joining lines of code, or making a multi-line string single-line.

I know I sometimes kill the space.

Though, as I’m trying to understand what the best mappings are empirically, I have a plan to make a table of most frequencies of key pairs. Let’s see…

---

<div class="post-metadata">

**Author:** ![eraserhd](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/eraserhd/32/15_2.png) [@eraserhd](https://discuss.kakoune.com/u/eraserhd)\
**Post date:** [December 8, 2018, 2:21pm UTC](https://discuss.kakoune.com/t/join-without-extra-whitespace/225/3 "2018-12-08T14:21:03Z")

</div>

> <https://gist.github.com/eraserhd/4555091b4a1b6e45e6386177e48b0787>

Not enough data to answer this empirically, I think.

---

<div class="post-metadata">

**Author:** ![Delapouite](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/delapouite/32/10_2.png) [@Delapouite](https://discuss.kakoune.com/u/Delapouite)\
**Post date:** [December 8, 2018, 4:28pm UTC](https://discuss.kakoune.com/t/join-without-extra-whitespace/225/4 "2018-12-08T16:28:30Z")

</div>

What you can do is `<a-J>`, it will join the lines and select the spaces between. Which means you can do `d` to delete them.

---

<div class="post-metadata">

**Author:** ![jbrains](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/jbrains/32/61_2.png) [@jbrains](https://discuss.kakoune.com/u/jbrains)\
**Post date:** [December 19, 2018, 1:19pm UTC](https://discuss.kakoune.com/t/join-without-extra-whitespace/225/5 "2018-12-19T13:19:55Z")

</div>

Thank you! I hadn’t noticed that kakoune was selecting the intervening spaces after `<a-J>`. They seemed to be doing the same thing, and I decided that I might be missing something, but I didn’t have the energy at the moment to figure that out.

Is there an easy way, then, to select 7 lines and apply -then-d to every line? or to apply a composite command like `g`-`l`-`<a-J>`-`d` 7 times in a row? (I guess this would be composing a macro?)

---

<div class="post-metadata">

**Author:** ![Screwtapello](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/screwtapello/32/12_2.png) [@Screwtapello](https://discuss.kakoune.com/u/Screwtapello)\
**Post date:** [December 20, 2018, 5:26am UTC](https://discuss.kakoune.com/t/join-without-extra-whitespace/225/6 "2018-12-20T05:26:40Z")

</div>

Your cursor doesn’t need to be on the line-end to join lines, so it’s a bit easier than that:

- `7X` to select seven lines, including the current one
- `<a-J>` to join them and select the inserted spaces
- `d` to delete the inserted spaces
