Skip to content

Commit 1f7b6a4

Browse files
Fix incorrect cursor position in capture template. Closes #94.
1 parent 09d3d87 commit 1f7b6a4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/orgmode/capture/templates.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,15 @@ end
5151

5252
function Templates:setup()
5353
local initial_position = vim.fn.search('%?')
54+
local is_at_end_of_line = vim.fn.search('%?$') > 0
5455
if initial_position > 0 then
5556
vim.cmd([[norm!c2l]])
56-
vim.cmd([[startinsert!]])
57+
if is_at_end_of_line then
58+
vim.cmd([[startinsert!]])
59+
else
60+
vim.cmd([[norm!l]])
61+
vim.cmd([[startinsert]])
62+
end
5763
end
5864
end
5965

0 commit comments

Comments
 (0)