When using gdb and Vim, often I want to stop on a particular line. Normally in Vim I copy-paste the line number showing on the rule area to the gdb session. It'd save me a lot of hassle if I could use something like "+<magic-incantation>
to copy the line number of the current cursor position into the xclipboard buffer. Is this possible?
views:
806answers:
4
A:
Not sure if this is what you're after but have you tried using markers?
Put the cursor on the line you want, then enter m and a letter, say a.
Entering 'a will take you to the line containing the marker.
Entering `a will take you to the actual letter that you marked in the line.
Hmm, just thinking a bit further, this must be available as the line number is available for use in various functions, e.g. for use in the status bar.
Rob Wells
2008-11-17 11:11:51
Nice try, but sadly the a buffer doesn't hold the line afterwards. Marks and yanks must use a different set of registers...
rq
2008-11-17 11:21:51
Bugger. Not sure about what you wanted this for but I assumed just navigation. Maybe add a bit more text to clarify the questions?
Rob Wells
2008-11-17 12:48:06
+7
A:
put this in your vimrc
map ,n <Esc>:let @*=line(".")<CR>
then using ,n will copy the current line number into the clipboard
Gowri
2008-11-17 11:27:00
+2
A:
So the magic line is:
:call setreg('*', line('.'))
The reason:
- The register * hold the clipboard
line('.')
holds the current line number
Of course you can map that function to a shortcut:
nmap ,ln :call setreg('*', line('.'))<CR>
PierreBdR
2008-11-17 11:32:33
A:
Also, to use GDB from within vim, you may want to check out some of the gdb scripts on vim.sourceforge.net -
Gowri
2008-11-17 11:33:56