# Great video demonstration of the power of multiple cursors

**URL:** <https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361>\
**Category:** Off Topic\
**Tags:** other-editors\
**Created:** [November 12, 2020, 1:06pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361 "2020-11-12T13:06:09Z")\
**Posts on this page:** 17\
**Page:** 1

<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:** [November 12, 2020, 1:06pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/1 "2020-11-12T13:06:09Z")

</div>

Hello

Once in a while, I stumble upon the following video and it never ceases to amaze me.  
This is a demonstration of workflow involving multiple cursors in… emacs.

> **[Emacs Rocks! Episode 13: multiple-cursors](http://emacsrocks.com/e13.html)**

If I’m not mistaken, it has not been shared yet on this forum. It last a bit more than 3 minutes, and I consider it a real treat, and hope you’ll like it as well if you’ve never seen it!

I particularly enjoy the last part where the author effortlessly compute the total view times of his videos just by copy-pasting the content of the Youtube page.

Obviously, the author had time to script his demo and rehearse the execution of the scenario, but it results in a very smooth flow which really feels like magic, even for people like us used to deal with multiple cursors all day long.

There are a few additional things that Kakoune can do that are not shown, like sub-selections, or alignment. On the other hand there’s also the last part involving the inline elisp expression (addition, division…) which is really powerful in emacs world.  
Also the fact that he acknowledge that macros also have their place is a good way to calm the haters.

Do you think such a video, but made with Kakoune, could have a positive benefit on how people perceive our favorite text-editor?

---

<div class="post-metadata">

**Author:** ![crdpa](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/crdpa/32/634_2.png) [@crdpa](https://discuss.kakoune.com/u/crdpa)\
**Post date:** [November 12, 2020, 2:27pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/2 "2020-11-12T14:27:44Z")

</div>

What he does in the video is basically what Kakoune is about. I use this daily, specially renaming a bunch of files with multiple cursors.

---

<div class="post-metadata">

**Author:** ![alexherbo2](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/alexherbo2/32/1140_2.png) [@alexherbo2](https://discuss.kakoune.com/u/alexherbo2)\
**Post date:** [November 12, 2020, 8:28pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/3 "2020-11-12T20:28:19Z")

</div>

@crdpa I’m interested for the rename stuff related. How do you rename files?

---

<div class="post-metadata">

**Author:** ![ftonneau](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ftonneau/32/295_2.png) [@ftonneau](https://discuss.kakoune.com/u/ftonneau)\
**Post date:** [November 12, 2020, 8:50pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/4 "2020-11-12T20:50:10Z")

</div>

In the case of Emacs, he is presumably working on Dired. As an alternative, I remember seeing some bash scripts around that allow you to open the current directory content in your favorite editor, work on the content as a regular text file (buffer), and rename the files as you save the text file and leave your editor. I am pasting the script I use below. (I copied it and adapted it from the web, but I can remember neither the source nor the original author.)

Notice that this is not Posix-compliant, because we use arrays.

```
#!/usr/bin/env bash

# This script allows you to rename files by editing the contents of the current
# directory.

editor=kak

# Store filenames into a 'cache' array and an editable 'project' file.

IFS=$'\n' read -d '' -r -a cache < <( ls -1 )

project=$(mktemp ./temp_1_XXX)

for item in "${cache[@]}"; do
    printf %s\\n "$item"
done > "$project"

# Save the edited project file into a 'text' array.

if ! "$editor" "$project"; then
    echo 'ren: files not renamed' >&2
    rm "$project"
    exit 1
fi

IFS=$'\n' read -d '' -r -a text < "$project"

# Read both arrays to move (rename) files one by one.

item_count=${#cache[@]}
target_count=${#text[@]}

if [[$item_count -ne $target_count]]; then
    echo 'ren: number of files differ' >&2
    rm "$project"
    exit 1
fi

for ((num = 0; num < item_count; num++)); do
    item=${cache[$num]}
    target=${text[$num]}
    if [[$item != $target]]; then
        mv "$item" "$target"
    fi
done

rm "$project"
ls -lh
```

---

<div class="post-metadata">

**Author:** ![ftonneau](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ftonneau/32/295_2.png) [@ftonneau](https://discuss.kakoune.com/u/ftonneau)\
**Post date:** [November 12, 2020, 8:52pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/5 "2020-11-12T20:52:56Z")

</div>

This script works well enough for me, but it is not foolproof. For example, it cannot handle filenames with line returns in them. So this is not for serious admin work. For a single person working on his/her own computer, however, this works great.

---

<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:** [November 12, 2020, 11:15pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/6 "2020-11-12T23:15:12Z")

</div>

I have [moreutils](https://joeyh.name/code/moreutils/) installed on my systems, so I use the `vidir` command.

---

<div class="post-metadata">

**Author:** ![robertmeta](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/robertmeta/32/833_2.png) [@robertmeta](https://discuss.kakoune.com/u/robertmeta)\
**Post date:** [November 12, 2020, 11:34pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/7 "2020-11-12T23:34:00Z")

</div>

Whelp, I didn’t know that existed, and it is awesome.

---

<div class="post-metadata">

**Author:** ![crdpa](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/crdpa/32/634_2.png) [@crdpa](https://discuss.kakoune.com/u/crdpa)\
**Post date:** [November 12, 2020, 11:59pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/8 "2020-11-12T23:59:04Z")

</div>

I use the nnn file browser. It has a bulkrename function that calls $EDITOR.

If i press ‘r’ in a directory, it shows all filenamess in the editor (or only the ones i selected). I just edit the names, save and quit.

I had a bash script i made for this when nnn didn’t have this function, but it was a long time ago and i lost it.

---

<div class="post-metadata">

**Author:** ![tgirod](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@tgirod](https://discuss.kakoune.com/u/tgirod)\
**Post date:** [November 16, 2020, 12:28pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/9 "2020-11-16T12:28:41Z")

</div>

This video is quite impressive! I wonder, is there a way to add new selections incrementally like it’s done in the video?

---

<div class="post-metadata">

**Author:** ![robertmeta](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/robertmeta/32/833_2.png) [@robertmeta](https://discuss.kakoune.com/u/robertmeta)\
**Post date:** [November 16, 2020, 4:30pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/10 "2020-11-16T16:30:50Z")

</div>

```
/foo
N

Ctrl+Mouse works as well
```

---

<div class="post-metadata">

**Author:** ![useredsa](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/useredsa/32/419_2.png) [@useredsa](https://discuss.kakoune.com/u/useredsa)\
**Post date:** [November 16, 2020, 9:07pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/11 "2020-11-16T21:07:38Z")

</div>

You forgot `C`

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [November 17, 2020, 12:15pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/12 "2020-11-17T12:15:02Z")

</div>

You can do it with `*` to add current selection to search register and then `N` to add the new occurence to the selections. ( or `n` to skip to the next one )

---

<div class="post-metadata">

**Author:** ![EpocSquadron](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/epocsquadron/32/78_2.png) [@EpocSquadron](https://discuss.kakoune.com/u/EpocSquadron)\
**Post date:** [November 17, 2020, 1:48pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/13 "2020-11-17T13:48:13Z")

</div>

I honestly feel like this video pales in comparison to what @gustavo-hms outlined in the thread on iterators recently. Maybe I’ll find some time to translate it to a video like this.

---

<div class="post-metadata">

**Author:** ![robertmeta](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/robertmeta/32/833_2.png) [@robertmeta](https://discuss.kakoune.com/u/robertmeta)\
**Post date:** [November 17, 2020, 4:30pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/14 "2020-11-17T16:30:16Z")

</div>

@EpocSquadron I think very short & single example videos would get a ton of traction. If I was making them, I would put them on youtube rather than like ttyrec because youtube is easy to embed into a forum like this… I might make some too!

---

<div class="post-metadata">

**Author:** ![gustavo-hms](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/gustavo-hms/32/598_2.png) [@gustavo-hms](https://discuss.kakoune.com/u/gustavo-hms)\
**Post date:** [November 18, 2020, 11:42pm UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/15 "2020-11-18T23:42:41Z")

</div>

> [@tgirod](#):
>
> is there a way to add new selections incrementally like it’s done in the video?

I usually use [this script](https://github.com/gustavo-hms/enluarada/tree/main/search-tools) to easily work with incremental selections. It’s just a small addition over the built-in `*` key, but it comes in handy.

---

<div class="post-metadata">

**Author:** ![yungcheeze](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/yungcheeze/32/684_2.png) [@yungcheeze](https://discuss.kakoune.com/u/yungcheeze)\
**Post date:** [November 28, 2020, 4:13am UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/16 "2020-11-28T04:13:33Z")

</div>

Been using [emv](http://www.i0i0.de/toolchest/emv).  
Came across it in [nixpkgs](https://search.nixos.org/packages?channel=20.09&show=emv&from=0&size=30&sort=relevance&query=emv) but only just realised it’s a shell script.

---

<div class="post-metadata">

**Author:** ![crdpa](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/crdpa/32/634_2.png) [@crdpa](https://discuss.kakoune.com/u/crdpa)\
**Post date:** [December 12, 2020, 11:20am UTC](https://discuss.kakoune.com/t/great-video-demonstration-of-the-power-of-multiple-cursors/1361/17 "2020-12-12T11:20:25Z")

</div>

This is what i do a lot with kakoune (and nnn):

[![asciicast](https://asciinema.org/a/378843.svg)](https://asciinema.org/a/378843)
