0

I am trying to get the output of the following function to an :execute statement such as I have this in my .vimrc

def GetBufAbsPath(): string
    return substitute(expand("%:p"), '[^\/]\+$', '', '')
enddef

noremap <F5> :execute '!echo ' ..  GetBufAbsPath() <CR>

And upon pressing I am getting

E117: Unknown function: GetBufAbsPath
1
  • I can't reproduce your problem :-| Could you share with us your version of Vim (:version)? Can you reproduce the problem with a very simple version of the .vimrc that you can share with us? Mar 18 at 13:10

1 Answer 1

1

I'd use CTRL-R= directly here. Also, it seems like you're trying to emulate expand('%:p:h')

nnoremap <silent> <F5> :<c-u>!echo <c-r>=expand('%:p:h')<cr><cr>

(I'm also not sure why you try to execute :!echo instead of :echo. Let's suppose this is for having a Minimal Working Example)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.