EmEditor (text editor) Forum Index Questions and Answers about EmEditor Core
Swap cpp and header files | Register To Post |
| Threaded | Newest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| parameter | Posted on: 3/5/2012 12:17 pm |
Not too shy to talk ![]() ![]() Joined: 3/5/2012 From: Posts: 30 |
Swap cpp and header files Is there a feature/hot key to switch between associated files? E.g. foo.h to foo.c or foo.cpp
|
| parameter | Posted on: 3/5/2012 2:17 pm |
Not too shy to talk ![]() ![]() Joined: 3/5/2012 From: Posts: 30 |
Re: Swap cpp and header files One way to do this in a more general way (i.e. not just c++) would be to have a command to rotate through the extensions (associations) for a given configuration.
So for HTML, if you were editing foo.htm when you executed the command then Emedit would look for foo.html, foo.asp, foo.aspx, foo.shtml, and foo.shtm in the same directory as foo.htm and open that file (whichever it found next). For C++, in my version of Emedit, it looks like that list would be cpp, cxx, c, h, hpp, inl, and rc. If I only had a foo.cpp and a foo.h file in that directory I'd effectively jump between the two associated files with this command. If I also had a foo.inl in that directory, I'd rotate between all three. I'm hoping this will make the feature request more appealing to implement as it will be more generally useful and elegant (vs. my initial request to jump between two files for one specific programming language). |
| Yutaka | Posted on: 3/6/2012 8:58 am |
Webmaster ![]() ![]() Joined: 9/28/2006 From: Redmond Posts: 2423 |
Re: Swap cpp and header files Hi parameter,
This is easily done by writing a macro. If you need a help writing the macro, please let me know. Thank you!
|
| parameter | Posted on: 3/6/2012 2:19 pm |
Not too shy to talk ![]() ![]() Joined: 3/5/2012 From: Posts: 30 |
Re: Swap cpp and header files It was pretty easy to get this far:
var current_file=document.FullName; var with_out_ext=current_file.substring(0, current_file.lastIndexOf(".")); var ext=current_file.substring(current_file.lastIndexOf(".")); switch (ext) { case ".cpp": ext = ".h"; break; case ".h": ext = ".cpp"; break; } editor.OpenFile(with_out_ext+ext, 0, eeOpenAllowNewWindow); But I haven't found where to get the list of extensions from the current configuration. I'm also not sure how to test if the file exists (so I can try the next file extension if it does not exist). Tips/suggestions welcome. |
| Threaded | Newest First | Previous Topic | Next Topic | Top |
| Register To Post | |




