Author Topic: How to switch between files in Code::Blocks editor window  (Read 3813 times)

Offline FrankPeelo

  • Single posting newcomer
  • *
  • Posts: 6
How to switch between files in Code::Blocks editor window
« on: September 24, 2025, 01:49:06 pm »
What is the best way to go between two files, e.g. between the header file and the code file, in Code::Blocks?

Ideally I would like to have them side by side, but "Split View" seems only to show the same file in both views. I want to check/modify the declaration of my function (or the documentation there) in the .hpp file when I am working on the definition in the .cpp file. Is it possible to split the view and have different files in the two views?

Alternatively, can I switch quickly between files without losing my train of thought?

I found a thread (https://forums.codeblocks.org/index.php?topic=19589.0) saying that ctrl-Tab should let me switch between windows. Maybe it worked in 2014; I can't quite get it to work properly, now. It only switches between editor tabs if I first click on the tab. If the focus is on the code, ctrl-tab gets me into the "Management" sidebar to the left of the editor window, and then starts bringing me through the tabs in there. Unless I put ctrl-TAB as the binding in Settings|Editor... ->Keyboard shortcuts -> View -> Switch tabs, but then I get the "tab-switcher window" discussed in that thread.

The setup is, Code::Blocks 25.03 installed from codeblocks_25.03_amd64_debian11.tar.xz on Ubuntu 22.04 LTS with Mate as the desktop environment.


Offline ccdric

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: How to switch between files in Code::Blocks editor window
« Reply #1 on: September 24, 2025, 03:28:04 pm »
first of all : something like "Hello" !!! and ending by something like "thank-you ...." would be nice

but as I'm in a good mood :
- switch quickly : for me shift-ctrl-tab works
- side by side :  open 2 file, drag and drop one of them on the right side .. works fine for me too 

Offline blauzahn

  • Almost regular
  • **
  • Posts: 209
Re: How to switch between files in Code::Blocks editor window
« Reply #2 on: September 24, 2025, 03:40:49 pm »
Swap header / source    F11

see https://wiki.codeblocks.org/index.php/Keyboard_Shortcuts

It is one of my favourite nifty little features of Code::Blocks besides F2 for opening/closing the log info pane.

Offline FrankPeelo

  • Single posting newcomer
  • *
  • Posts: 6
Re: How to switch between files in Code::Blocks editor window
« Reply #3 on: Yesterday at 01:06:45 pm »
- switch quickly : for me shift-ctrl-tab works
- side by side :  open 2 file, drag and drop one of them on the right side .. works fine for me too

Thanks for that @ccdric, shift-ctrl-tab gets me to the tab without using the mouse, which is an improvement. Then ctrl-tab lets me change which file I'm looking at, although not to toggle back to the one I was at before.

The side by side option sounds very interesting! But I can't get it to work.
Now there are multiple source files open in Code::Blocks. The name of each file is in a tab at the top of the editor window. First file is showing in the editor, I should drag and drop another on its right.
  • If I try to drag the second file's tab at the top of the C::B editor window, as soon as I click on it I move to that file instead of being able to drag it.
  • If I drag the filename from the "Projects" tab in the C::B management pane, the path of the file is inserted into the file.
  • If I drag from the "Files" tab in the C::B management pane, nothing happens.
  • If I drag from the file browser, the file I drag opens in its own tab.
 

Sorry, I would like to use your hint but I can't figure it out.

Thanks anyway.

Offline blauzahn

  • Almost regular
  • **
  • Posts: 209
Re: How to switch between files in Code::Blocks editor window
« Reply #4 on: Yesterday at 01:15:30 pm »
I have the open file list window attached to the right side of the cb-window, next to the editor. In addition to that I have set in settings|editor|other editor setttings| Label in editor tab is the file's to relative path. The tabs on top or bottom of the editor window fill up available space quickly but navigating via the open file list works well for me even when I have dozens of files opened.

At the bottom I prefer to have the logs getting the full width.

Offline FrankPeelo

  • Single posting newcomer
  • *
  • Posts: 6
Re: How to switch between files in Code::Blocks editor window
« Reply #5 on: Yesterday at 01:19:30 pm »
Swap header / source    F11

see https://wiki.codeblocks.org/index.php/Keyboard_Shortcuts

It is one of my favourite nifty little features of Code::Blocks besides F2 for opening/closing the log info pane.

Thanks, the link is now bookmarked. It does say ctrl-tab should cycle through recent files, it's provided by the Code::Blocks' editor component and cannot be rebound. But it doesn't work on my machine, which is a pity.

The "Swap header / source" function is great though, I now have a key bound to that, and it's a big help.

Thanks

Frank

Offline FrankPeelo

  • Single posting newcomer
  • *
  • Posts: 6
Re: How to switch between files in Code::Blocks editor window
« Reply #6 on: Yesterday at 01:36:38 pm »
The tabs on top or bottom of the editor window fill up available space quickly but navigating via the open file list works well for me even when I have dozens of files opened.

Yes, but the problem is I want to hop back to where I was a couple of minutes ago, and I have to figure out what file that was!

I have Settings | Environment... | Notebooks appearance -> Use stacked based tab-switching checked, and I was hoping ctrl-tab would bring me back to where I came from.

After posting the question yesterday I found a nice key binding, "Goto declaration", which is brilliant, got to the right header file in a completely different class. But then I was trying to remember where I was before and why I wanted to look up that function -- Bit like sometimes these days when I go upstairs, I'm wondering what I went up for...


Offline ccdric

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: How to switch between files in Code::Blocks editor window
« Reply #7 on: Yesterday at 02:06:28 pm »
[
  • If I try to drag the second file's tab at the top of the C::B editor window, as soon as I click on it I move to that file instead of being able to drag it.
 


I'm no sure I understand very well (I'm not natural English speaking)
but for me I can move the editor tab if the tab is the selected one, if not it just select it.
just move it on the right border slowly until a blue "ghost" windows appears in the center of the editor,  then release it. it should do what I understand you wants.


Offline blauzahn

  • Almost regular
  • **
  • Posts: 209
Re: How to switch between files in Code::Blocks editor window
« Reply #8 on: Yesterday at 06:52:14 pm »
Quote
Yes, but the problem is I want to hop back to where I was a couple of minutes ago, and I have to figure out what file that was!

Please have a look at the Browse Tracker plugin. I do not use it myself but here is the wiki page:

https://wiki.codeblocks.org/index.php/Browse_Tracker_plugin