Soup  Endless
Soup Endless

Reputation: 443

vim copy to buffer gdb breakpoint command string

I need to copy in buffer line of below form by pressing sequence \br in vim command mode

br /absolute_path/current_file : cursor_line

I think it should be similar to this:

:noremap <silent> \fn :let @*=expand('%:p')<CR>:echo "filename copied: ".@*<CR>

Thank you!

Upvotes: 1

Views: 139

Answers (1)

sudavid4
sudavid4

Reputation: 1141

I'm not sure I fully understand you question but looks like you're very close. If all you want is to copy the current filename you should write it like this:

:noremap <silent> \fn :execute "let @*='".expand('%:p')."'"<cr>:echo "filename copied: ".@*<cr>

if what you want is filename:currentLineNumber then you should write this instead

:noremap <silent> \fn :execute "let @*='".expand('%:p').":".getpos('.')[1]."'"<cr>:echo "filename copied: ".@*<cr>

if what you want is filename:contentsOfCurrentCursorLine then use this instead

:noremap <silent> \fn :execute "let @*='".expand('%:p').":".getline('.')."'"<cr>:echo "filename copied: ".@*<cr>

Upvotes: 2

Related Questions