Gin muyi
Gin muyi

Reputation: 15

How to Map “Termdebug” Shortcuts in Vim

I want to use F2 to enter Termdebug immediately.

It's convenient to put file's name after the command like: Termdebug xxx (which has complied with -g option)

My host is Windows 11 and use VMware, which contains Ubuntu 22.04 LTS version. I use following command in ~/.vimrc:

nnoremap <F2> :call RunTermdebug()<CR>
function! RunTermdebug()
    let filename = expand('%:t:r')
        let e_f=fnameescape(filename)
    execute "Termdebug ".e_f
endfunction

But it failed. The vim console shows that the result will become RunTermdebug()

If I change like this:

function! RunTermdebug()
    let filename = expand('%:t:r')
    execute "Termdebug"." ".filename
endfunction

Still doesn't work, the same result as above.

If I change like this:

function! RunTermdebug()
    let filename = expand('%:t:r')
    execute "Termdebug".filename
endfunction

The command seems like: Termdebugxxx, but I need blank between them.

I also use \ or <space> but it still doesn't work.

Is there any nice plugin, software or method you are using or recommend?

Upvotes: 0

Views: 123

Answers (0)

Related Questions