I have this code intended to:
- read current line
- extract variable from end of line, looking for text like
#ad04e482
- search for filename that begins with the string
ad04e482
- open that file to edit in vim
- bind this to a few keystrokes
<leader>tn
I'm struggling to define and use these variables inside the execute
function calls...
function TaskSearch()
let line = getline('.')
let task_id = split(line, "#")[1]
let task_note = execute('find ~/.task/notes/ -name "task_id*"')
execute('edit ~/.task/notes/$task_note')
endfunction
command! TaskSearch :call TaskSearch()
nnoremap <leader>tn :TaskSearch <Enter>
I've tried many different variatlions of the let task_note...
and execute(...)
statements without any success.
I've looked through various posts on the stack network but I haven't seen any examples using a vimscript variable (like task_id
in my case) inside a shell command's arguments.
I need to take the results of that command, which should be just a single file, and then open that file in a new buffer to edit it. How can I achieve this?