Add function for command line in and out
parent
98df147ad8
commit
8c7329b1d6
|
|
@ -62,4 +62,20 @@ function M.in_and_out()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.in_and_out_cmd()
|
||||||
|
local current_pos = vim.fn.getcmdpos()
|
||||||
|
|
||||||
|
local target_pos = nil
|
||||||
|
local line = vim.fn.getcmdline()
|
||||||
|
for _, char in ipairs(targets) do
|
||||||
|
local found_pos = string.find(line, escape_lua_pattern(char), current_pos + 1)
|
||||||
|
if found_pos and (not target_pos or found_pos < target_pos) then
|
||||||
|
-- If char is a multibyte character, we need to take into account the extra bytes.
|
||||||
|
target_pos = found_pos + vim.fn.strlen(char) - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if target_pos then
|
||||||
|
vim.fn.setcmdpos(target_pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue