Templater icon indicating copy to clipboard operation
Templater copied to clipboard

`tp.file.cursor` multi cursor not working when started from vim normal mode

Open lyndhurst opened this issue 2 years ago • 3 comments

Plugin information:

  • OS: Kubuntu 16
  • Templater version: 1.16
  • Obsidian version: 1.0.3

Describe the bug When using same order number as an argument for tp.file.cursor, the multi cursor functionality does not work as expected:

  1. Use the command to navigate to the first cursor instance
  2. The first instance gets replaced by a first cursor as expected, but additional cursors are simply placed on the next lines under the the first cursor no matter where other tp.file.cursor instances are located.

Example:

The following template:

---
title:  <% tp.file.cursor(1) %>
---

#  <% tp.file.cursor(1) %>

Gives

---
title: Test
---Test

#

Additional context

  1. I also tried with simple spaced out lines without any front matter or headers to make sure nothing was interfering.
  2. I use the vim cursor feature.

Thanks for your time.

lyndhurst avatar Dec 15 '22 20:12 lyndhurst

I didn't know about the multi-cursor functionality, that is so cool!

I just tried this in my vault and it worked as expected, using your exact template. Maybe there's another plugin conflicting? Have you tried in the sandbox vault with just the Templater plugin enabled?

Zachatoo avatar Dec 17 '22 22:12 Zachatoo

I did not know about the sandbox feature, this is pretty helpful, thanks @Zachatoo .

As I suspected, the "vim keybindings" option interferes with the multi cursor functionality.

To be more specific, the bug occurs only when the "jump to next cursor location" command is executed in "vim normal mode", if I issue the command while in "vim insert mode", everything works as expected.

So I am going to edit the title, and let the developer decide if it is worth fixing.

lyndhurst avatar Dec 18 '22 09:12 lyndhurst

I have the same issue! Since the problem seems to be with the vim keybindings I reported it on the Obsidian forum (https://forum.obsidian.md/t/vim-in-normal-mode-templater-multi-cursors-with-tp-file-cursor-1-not-placed-properly/52166) but they won't look at it because it involves a plugin.

This might be related to issue https://github.com/SilentVoid13/Templater/issues/1089

tprotopopescu avatar Apr 19 '23 13:04 tprotopopescu