I want that whenever i open a new c++ file in vim in linux ( mandriva 2010 ) the following code gets inserted in it automatically :
Default code :
#include <iostream>
using namespace std;
int main()
{
return 0;
}
Is there any way to get it done. also can i bind .py, .pl, .java files with similar things. Moreover i should be able to change the default code for a file.
For customizable headers, code completion, as well as a host of other features specific to C++, try c.vim
One common method for doing this is described at :help template.
Another option would be to use a snippets plugin (like snipMate or UltiSnips). These don't automatically insert the code when you open a new file, but you can create various snippets that will expand to portions of the template you describe and let you fill in the portions that vary (like the header in an #include <...> statement).
Regarding C&C++, muTemplate goes a step further. When creating a new source file (.cpp, .c, ...), if a header file with the same base name is detected in the vicinity, it is automatically included -- in the case the alternate plugin (a.vim) is installed, its detection heuristic is automatically exploited (in some projects, source files and header files are not in the same directory).
NB: files headers (i.e. copyright/VCS stuff can be overridden)
Related
I have a .h file who contains these code:
template<BLA>
func1() {}
// something
template<BLA>
func2() {
func1();
}
when I typed the command GoToDefinition, the error appeared :"YCM : 'RuntimeError : can't jump to definition.'".
Do I miss something? And how to find the definition?
By the way, I have this in my .vimrc:
let g:ycm_global_ycm_extra_conf = ' ~/ycm_extra_conf.py'
**************second edit*******************
I reinstalled my YCM, and I tried ctags for YCM by this command :
ctags -R --fields=+l
It works, and thanks.
Last time I've checked, YCM understanding of a source code is restricted to one translation unit. It'll be very difficult for it to find where a function is defined as it's likely to be in another translation unit.
In other words, it should work as long as you want to jump to a definition that is in the same .cpp file as the one your are currently editing.
Thus, it should also work when trying to access to a template function definition from it's call site -- as we're supposed to include the related code. If it doesn't, it could be related to an improper understanding of the source code by clang engine YCM is using, or to YCM not configured to use clang.
Regarding tags, they could do the job, but indeed, in C++, you'll want a way to narrow the tags presented. That's what had me started lh-tags: it presents all matching tags and it permits to filter them on various criteria (filename, kind, scope, ...)
Is it possible to obtain a list of preprocessor #define'd symbols in VC++? I know GCC has similar options to dump all effective #define symbols for the supplied .cpp/.h source files, but I am not sure if VC++ support this?
I am using a Mozilla open source project in Windows. There are a lots of irrelevant #define for the UNIX build env causing the source code very unreadable. I want to eliminate the irrelevant #define from the source code. The project uses Mozilla specific build scripts (automake, configure, Makefile, python scripts, and etc) to supply the symbol definitions to the compiler dynamically. Also each source file add its own #define at different #ifdef branches making manually pre-determining the complete list of symbols for a specific build impractical.
Check out Macros and Constants list in the View => Class View menu.
I need to use Visual C++ to build a customized Apache web server. Here is the goal I am trying to achieve: specify some of the functions or data in Apache source code, and put them in separate and 4k-page aligned sections (not .text .data .bss) of output .exe file.
The closet solution I can find online is use /Gy compiler options to compile each functions into different COMDATs, and then use /ORDER linker options to put the COMDATs in a predetermined order. However, it is just reordering inside a section, not changing the section layout in .exe output or creating a new section. Under Linux, I can use compiler attribute "section" and linker script to fulfill my goal. Are there equivalent solution in Visual C++? Thanks very much:-)
#pragma code_seg lets you specify the segment into which code will be placed. Along with being able to specify a name, the compiler keeps a stack of names so you can push and pop the current state if you want.
I'm creating an installation script that I'd like to break up into smaller, more manageable pieces. Is there a way for an Inno Script file to have an INCLUDE or a reference to another ISS script file that is separate and has a different function overall to play during installation but becomes an integrated part of the full installation itself?
Consider:
ProgramInstall.iss
SQLInstall.iss
SOAPInstall.iss
ProgramInstall would have an include to the other scripts and return one full EXE that did the job as if they were all in one large file.
Not only would this be helpful for management purposes but would allow me to reuse scripts that are tested and working with other main application installation projects. Thanks for any assistance.
Well - I guess finding the right section of the CHM file is always helpful:
http://www.jrsoftware.org/ishelp/index.php?topic=scriptformatoverview
Inno-Setup seems to include an C-like #include directive.
A C-like #include directive is supported, which pulls in lines from a
separate file into the script at the position of the #include
directive. The syntax is:
#include "filename.txt"
If the filename is not fully qualified, the compiler will look for it
in the same directory as the file containing the #include directive.
The filename may be prefixed by "compiler:", in which case it looks
for the file in the compiler directory.
I want to make a "standard" install for external use, but I also want to use the same script and tell it (with a command line param perhaps?) to include another set of files (PDB files for debugging) for our lab installations. (And make a totally different install exe)
How can I do this? Is it possible?
I don't see how to set this in the [Files] section (conditionally add files based on some value/param)
Note – this is not for allowing the user an option DURING the install. I want a build-time option to set in my hudson build or batch file.
I suppose I can just create a separate installer for the pdbs, but I'd rather just have one file to do everything.
You can simply use
#ifdef DebugVersion
File: *.pdb ...
#endif
and then call the Inno compiler like this:
iscc.exe -DDebugVersion ...
I'd also add something like this so you get different output file names:
#ifdef DebugVersion
OutputBaseFileName=mysetup-dbg
#else
OutputBaseFileName=mysetup
#endif
Note that you'll probably need the InnoSetup precompiler for this, which, for some inexplicable reason, is not part of the default InnoSetup package. The easiest way to get it is to get the "Quick Start Pack" from the InnoSetup download page.
The answer is simple: create two files for each release, but put the common stuff in a third file and #include it in the other two.
http://rickborup.blogspot.com/2006/09/inno-setup-include-directive.html