Initial window split in termdebug vim
Asked Answered
I

2

10

I am new to vim and recently came to know that we can use Termdebug to debug code in vim with gdb. I liked this very much as i was searching for a good vim integration with gdb. When i launch Termdebug window is split horizontally in gdb window, program window & source code window. I like to vertically split source code window to right. For that, currently i move focus on source code window and press Ctrl+w & L.

Before splitting:

enter image description here

After splitting:

enter image description here

This i have to do every time i launch Termdebug. Is there a way to .vimrc so that when i launch Termdebug, source code window is automatically splitted to right. I have seen here which suggests to use:

let g:termdebug_wide = 163

This does automatic splitting but it has some problem in highlighting lines during debug as can be seen in picture below:

enter image description here

Please suggest how can i change .vimrc

Immunotherapy answered 20/10, 2019 at 7:52 Comment(0)
T
15

This layout—with the editor on the right, and both GDB windows split horizontally on the left—can be set by configuring g:termdebug_wide in your .vimrc.

let g:termdebug_wide=1

See :help termdebug_wide for details.

I wrote a blog post on termdebug last year (May 2019), and recently (April 2020) addressed this same issue in a comment: https://www.dannyadam.com/blog/2019/05/debugging-in-vim/#comment-251004

Talion answered 6/5, 2020 at 23:47 Comment(0)
I
6

Finally, I found how to do this by modifying vimrc. I mapped the whole sequence of keys to F6 for convenience.

autocmd filetype cpp nnoremap <F6> :Termdebug %:r<CR><c-w>2j<c-w>L

I added the above line in vimrc. Now, when i press F6 automatically opens windows with source code window on right like in the question above with no strange behavior.

Explanation:

  • :Termdebug %:r<CR> This will open Termdebug with all 3 windows horizontally.
  • <c-w>2j This will move focus to the source code window.
  • <c-w>L This will move source code window to the right.

Note: If you want focus back on the gdb window, you can add <c-w>h at the end of the above line.

Immunotherapy answered 10/11, 2019 at 12:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.