Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: cyanide911 on November 16, 2009, 06:45:19 pm

Title: Quick new C++ file (small question)
Post by: cyanide911 on November 16, 2009, 06:45:19 pm
Currently it's a long process - File->New->File->C/C++ source->C++->Filename.
Is there way to simply open an Untitledx.cpp file with a single/fewer clicks, and then specify the filename while saving it? (or a similar shorter method)
Title: Re: Quick new C++ file (small question)
Post by: zabzonk on November 16, 2009, 08:41:16 pm
I just right-click on the relevant directory in the Workspace tree and select Add Files... This pops up the standard Windows file open dialog, which allows you to create new files from its context menu. Of course, this doesn't allow you to use CB templates, but I've never liked that feature in any IDE I've used.
Title: Re: Quick new C++ file (small question)
Post by: Jenna on November 16, 2009, 09:28:53 pm
I just right-click on the relevant directory in the Workspace tree and select Add Files... This pops up the standard Windows file open dialog, which allows you to create new files from its context menu. Of course, this doesn't allow you to use CB templates, but I've never liked that feature in any IDE I've used.

Does not work on linux (at least not in xfce).

What about using ctrl+shift+n, answering the popup-dialog with yes and type a name, or if it should not be added to a project, click no and save with ctrl+s, type a name and that's it.
Title: Re: Quick new C++ file (small question)
Post by: Radek on November 16, 2009, 10:06:46 pm
I add an empty file and then I write my code. Then I save the file with the .cpp extension. This seems to work, at least I haven't seen any misunderstandings. Perhaps, the online parser guess the file contents form "signals", like #include, #ifdef, typical syntax constructs and so on.
Title: Re: Quick new C++ file (small question)
Post by: cyanide911 on November 17, 2009, 10:14:12 am
Yeah, but the problem with writing the code in an empty file (without .cpp extension) is syntax highlighting. CodeBlocks will hilight the syntax only if it know that I'm making a C++ file.
@Jens: CtrlShiftN opens an empty file without any popup for the file name.
Title: Re: Quick new C++ file (small question)
Post by: Zini on November 17, 2009, 10:29:12 am
I think this sequence

Quote
File->New->File->C/C++ source->C++->Filename

could easily be reduced by one step by integrating the C++ part into the C/C++ source part.

We are already choosing what type of file we want at that stage. Why have another stage to choose the language?

The file type list would then look like this:
C header, C++ header, C source, C++ source, Empty file
Title: Re: Quick new C++ file (small question)
Post by: Jenna on November 17, 2009, 11:05:54 am
Yeah, but the problem with writing the code in an empty file (without .cpp extension) is syntax highlighting. CodeBlocks will hilight the syntax only if it know that I'm making a C++ file.
@Jens: CtrlShiftN opens an empty file without any popup for the file name.
The popup only occurs, if a project is open, if not, ctrl+s tries to save the file and asks for a name, if you now save with cpp-ending, you have c++ syntax-highlighting.
Title: Re: Quick new C++ file (small question)
Post by: dmoore on November 18, 2009, 04:20:34 pm
Yeah, but the problem with writing the code in an empty file (without .cpp extension) is syntax highlighting. CodeBlocks will hilight the syntax only if it know that I'm making a C++ file.
@Jens: CtrlShiftN opens an empty file without any popup for the file name.
The popup only occurs, if a project is open, if not, ctrl+s tries to save the file and asks for a name, if you now save with cpp-ending, you have c++ syntax-highlighting.

also don't forget edit->highlight mode->[your language]