I am using Neovim and I want to go to insert mode at the end of this command.
vim.cmd([[command! DunB lua run_only_current_file("below") ]])
I have tried | startinsert
and | :startinsert
.
but it did not work. The error says unexpected symbol near |
.
I also put an i
at the end of the command but it typed the whole command in the editor.
This is my function if it help:
function run_only_current_file(direction)
local name=vim.fn.expand('%:t')
local compiler="python" --defult
local format=vim.fn.expand('%:e'):match('[^.]+$')
if format== 'py' then
compiler="python"
end
if format== 'js' then
compiler="node"
end
vim.api.nvim_feedkeys(":" ..direction.. " split term://cd %:p:h &&" ..compiler.. " %:t\n","n", false)
end
:norm! A
:execute 'lua run_only_current_file("below")' | startinsert
;:lua
is not documented as consuming the bar, but it probably does (:python
and:perl
do):norm! A
gets error :function arguments expected near '!'
. andexecute ....
will type the content of the command in the editor.