Source insight does not provide such shortcuts. Sometimes it is annoying to use them. Finally, I found the method: Use the macro command and set the shortcut key to bind to it.
1. Open Source insight, project-> open project, and open base project. Note: The base project is created by default by source insight.
2. Open the utils. Em file and add the following content to the end of the file:
/* CPP and HPP file Interchange (currently only files in the same directory can be exchanged) */macro switch_cpp_hpp () {hwnd = getcurrentwnd () hcuropenbuf = getcurrentbuf () if (Bytes = 0) Stop curopenfilename = getbufname (hcuropenbuf) bytes = strlen (curopenfilename) // file type temporary buffer strfileext = newbuf ("strfileextbuf") clearbuf (strfileext) // header file type index_hpp_begin = 0 // the header file starts indexing appendbufline (strfileext ,". H ") appendbufline (strfileext ,". HPP ") Index_hpp_end = getbuflinecount (strfileext) // header file end index // source file type index_cpp_begin = index_hpp_end // source file start index appendbufline (strfileext ,". C ") appendbufline (strfileext ,". CPP ") appendbufline (strfileext ,". cc ") appendbufline (strfileext ,". CX ") appendbufline (strfileext ,". cxx ") index_cpp_end = getbuflinecount (strfileext) // end index of the source file iscppfile = 0 // 0: Unknown 1: header file 2: source file, default unknown extension curopenfileext =" "// currently open File Extension Index = index_hpp_begin // traverses the header file to determine whether the file is currently opened as the header file type while (index <index_cpp_end) {curext = getbufline (strfileext, index) curextlen = strlen (curext) curopenfileext = strmid (curopenfilename, folder-curextlen, folder) // the extension of the currently opened file // debug // encrypt (debugbuf, curext) // appendbufline (debugbuf, curopenfileext) if (curopenfileext = curext) // match successful {If (index <index _ Hpp_end) iscppfile = 1 // The current open file is the header file else iscppfile = 2 // source file break} Index = index + 1} // while (index <index_cpp_end) // debug // appendbufline (debugbuf, iscppfile) index_replace_begin = index_hpp_begin index_replace_end = index_hpp_end if (iscppfile = 1) // The current file opened is the header file {index_replace_begin = index_cpp_begin index_replace_end = index_cpp_end} else if (iscppfile = 2) // The current file opened is the source file {index_replac E_begin = index_hpp_begin index_replace_end = index_hpp_end // debug // appendbufline (debugbuf, "CPP")} else // unknown type {// closebuf (strfileext) // disable the buffer // stop index_replace_begin = 9999 index_replace_end = index_replace_begin // The following loop will not be executed} Index = while (index <index_replace_end) {destext = getbufline (strfileext, index) destfilename = strmid (curopenfilename, 0, curopenfilenamelen -Strlen (curopenfileext) // excluding the extension, absolute path // try to see if the current target extension can open destfilepath = CAT (destfilename, destext) // file name (including extension) hcuropenbuf = openbuf (destfilepath) if (hcuropenbuf! = 0) {setcurrentbuf (hcuropenbuf) break} // try to replace the directory to see if the file can be opened (how to design: support multiple directories )//... (not supported by likes) Index = index + 1} closebuf (strfileext) // disable the buffer // debug // appendbufline (debugbuf, "finished ")}
3. Close the base project and re-open source insight.
4. Open option-> key assignments. Select "macro: switch_cpp_hpp" in the Command column, click the assign new key button to set the shortcut key (CTRL + ·), and click OK.
5. Open another project and try the shortcut key you just set !!!
This article is purely reproduced, original address: http://blog.csdn.net/lizhongkan/article/details/7081412