"############################################################################################### " " Filename: c.vim " " Description: Write C/C++ programs by inserting complete statements, idioms and comments. " Compile, link and run one-file-programs without a makefile. " " Code and comments should have a professional appearance and should be " easy to write and maintain. " Programs with a consistent style are easier to read and understand. " The standardization of comments makes it possible to automate the search " for information and the generation of documents from the source code. " " GVIM Version: 6.0+ " " Author: Dr.-Ing. Fritz Mehner " Fachhochschule Südwestfalen, 58644 Iserlohn, Germany " " Email: mehner@fh-swf.de " " Usage: (1.0) Configure c.vim (section Configuration below). " (2.1) Load c.vim manually into VIM with the 'so' command: " :so ~//c.vim " or better " (2.2) Load c.vim on startup (VIM version 6.0 and higher) : " move this file to the directory ~/.vim/plugin/ " " c.vim inserts an additional menu entry into the Tools-menu for " loading/unloading this C support. " " Note: The register z is used in many places. " " Style Guides: Some ideas are taken from the following documents (recommended!): " " 1. Recommended C Style and Coding Standards (Indian Hill Style Guide) " www.doc.ic.ac.uk/lab/secondyear/cstyle/cstyle.html " 2. Pprintf ("\n");rogramming in C++, Ellemtel Telecommunication Systems Laboratories " www.it.bton.ac.uk/burks/burks/language/cpp/cppstyle/ellhome.htm " 3. C++ Coding Standard, Todd Hoff " www.possibility.com/Cpp/CppCodingStandard.html " let s:C_Version = "2.8" " version number of this script; do not change " " Revision: 17.02.2003 " Created: 04.11.2000 " " Copyright: Copyright (C) 2000-2003 Dr.-Ing. Fritz Mehner " " This program is free software; you can redistribute it and/or modify " it under the terms of the GNU General Public License as published by " the Free Software Foundation; either version 2 of the License, or " (at your option) any later version. " " This program is distributed in the hope that it will be useful, " but WITHOUT ANY WARRANTY; without even the implied warranty of " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " GNU General Public License for more details. " " You should have received a copy of the GNU General Public License " along with this program; if not, write to the Free Software " Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA " "############################################################################################### " " Configuration (Use my configuration as an example) " "------------------------------------------------------------------------------------- " let s:C_AuthorName = "Dr.-Ing. Fritz Mehner" let s:C_AuthorRef = "Mn" " " The following entries do not appear if the strings are empty. " let s:C_Email = "mehner@fh-swf.de" let s:C_Company = "Fachhochschule Südwestfalen, Iserlohn" let s:C_Project = "" " " Copyright information " --------------------- " If the code has been developed over a period of years, each year must be stated. " If C_CopyrightHolder is empty the copyright notice will not appear. " If C_CopyrightHolder is not empty and C_CopyrightYears is empty, " the current year will be inserted. " let s:C_CopyrightHolder = "" let s:C_CopyrightYears = "" " "############################################################################################### " " Global Variables : Compiler, Options, Libraries, ... " let s:C_CExtension = "c" " C file extension; everything else is C++ let s:C_CCompiler = "gcc" " the C compiler let s:C_CplusCompiler = "g++" " the C++ compiler let s:C_CFlags = "-Wall -g -O0 -c" " compiler flags: compile, don't optimize let s:C_LFlags = "-Wall -g -O0" " compiler flags: link , don't optimize let s:C_Libs = "-lm" " libraries to use " " The menu entrie 'run with pager' will not appear if the following string is empty let s:C_Pager = "less" " pager " " The menu entries for code snippet support will not appear " if the following string is empty " let s:C_CodeSnippets = $HOME."/.vim/codesnippets-c" " let s:C_ShowMenues = "no" " show menues immediately after loading this file (yes/no) " " "############################################################################################### " " ... finally " " Johann Wolfgang von Goethe (1749-1832), the greatest of the german men of letters, " about LINUX, Vim/gVim and other great tools (Ok, almost.) : " " "Ein Mann, der recht zu wirken denkt, "Who on efficient work is bent, " Muß auf das beste Werkzeug halten." Must choose the fittest instrument." " " Faust, Teil 1, Vorspiel auf dem Theater Faust, Part 1, Prologue for the Theatre " "############################################################################################### " "----- some variables for internal use ---------------------------------------- " let s:C_ExeCmdLineArgs = "" " command line arguments for Run-run; initially empty let s:C_MakeCmdLineArgs = "" " command line arguments for Run-make; initially empty let s:C_ClassName = "" " remember class name ; initially empty " "------------------------------------------------------------------------------ " C : C_InitC " Initialization of C support menus "------------------------------------------------------------------------------ " function! C_InitC () " "=============================================================================================== "----- Menu : Key Mappings --------------------------------------------------------------------- "=============================================================================================== " The following key mappings are for convenience only. " Comment out the mappings if you dislike them. " If enabled, there may be conflicts with predefined key bindings of your window manager. "----------------------------------------------------------------------------------------------- " Alt-F9 write buffer and compile " F9 compile and link " Ctrl-F9 run executable " Shift-F9 run make " map :call C_Compile() map :call C_Link() map :call C_Run(0) map :call C_Make() " imap :call C_Compile() imap :call C_Link() imap :call C_Run(0) imap :call C_Make() " " if(s:C_CopyrightYears=="") let s:C_CopyrightYears = strftime("%Y") " the default endif " "----- for developement only ------------------------------------------------------------------- " "noremap :write:so %:call C_Handle():call C_Handle():call C_Handle() "inoremap :write:so %:call C_Handle():call C_Handle():call C_Handle() " "=============================================================================================== "----- Menu : C-Comments ----------------------------------------------------------------------- "=============================================================================================== " amenu &Comments.&Line\ End\ Comment A// amenu &Comments.&Frame\ Comment :call C_CommentFrame() jA amenu &Comments.F&unction\ Description :call C_CommentFunction() :/NameA amenu &Comments.&Main\ Description :call C_CommentMain() :/DescriptionA amenu &Comments.-SEP1- : amenu &Comments.Mðod\ Comment :call C_CommentMethod():/MethodA amenu &Comments.Cl&ass\ Comment :call C_CommentClass():/DescriptionA amenu &Comments.Clea&r\ Class\ Name :call C_CommentClearClassNmae()i amenu &Comments.-SEP2- : amenu &Comments.File\ &Prologue :call C_CommentFilePrologue():/DescriptionA amenu &Comments.-SEP3- : " "----- Submenu : H-Comments : file sections ------------------------------------------------------------- " amenu &Comments.&H-File\ Sections.&Header\ File\ Includes \:call C_CommentSection("HEADER FILE INCLUDES")0i amenu &Comments.&H-File\ Sections.Exported\ &Macros \:call C_CommentSection("EXPORTED MACROS")0i amenu &Comments.&H-File\ Sections.Exported\ &Data\ Types \:call C_CommentSection("EXPORTED DATA TYPES")0i amenu &Comments.&H-File\ Sections.Exported\ &Type\ Def\. \:call C_CommentSection("EXPORTED TYPE DEFINITIONS")0i amenu &Comments.&H-File\ Sections.Exported\ &Variables \:call C_CommentSection("EXPORTED VARIABLES")0i amenu &Comments.&H-File\ Sections.Exported\ &Funct\.\ Decl\. \:call C_CommentSection("EXPORTED FUNCTION DECLARATIONS")0i amenu &Comments.&H-File\ Sections.-SEP4- : amenu &Comments.&H-File\ Sections.Exported\ &Class\ Def\. \:call C_CommentSection("EXPORTED CLASS DEFINITIONS")0i amenu &Comments.&H-File\ Sections.-SEP5- : amenu &Comments.&H-File\ Sections.&All\ Sections,\ C \:call C_Comment_H_SectionAll1()0i amenu &Comments.&H-File\ Sections.All\ &Sections,\ C++ \:call C_Comment_H_SectionAll2()0i " "----- Submenu : C-Comments : file sections ------------------------------------------------------------- " amenu &Comments.&C-File\ Sections.&Header\ File\ Includes \:call C_CommentSection("HEADER FILE INCLUDES")0i amenu &Comments.&C-File\ Sections.Local\ &Macros \:call C_CommentSection("MACROS - LOCAL TO THIS SOURCE FILE")0i amenu &Comments.&C-File\ Sections.Local\ &Data\ Types \:call C_CommentSection("DATA TYPES - LOCAL TO THIS SOURCE FILE")0i amenu &Comments.&C-File\ Sections.Local\ &Type\ Def\. \:call C_CommentSection("TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE")0i amenu &Comments.&C-File\ Sections.Local\ &Variables \:call C_CommentSection("VARIABLES - LOCAL TO THIS SOURCE FILE")0i amenu &Comments.&C-File\ Sections.Local\ P&rototypes \:call C_CommentSection("PROTOTYPES - LOCAL TO THIS SOURCE FILE")0i amenu &Comments.&C-File\ Sections.&Exp\.\ Function\ Def\. \:call C_CommentSection("FUNCTION DEFINITIONS - EXPORTED FUNCTIONS")0i amenu &Comments.&C-File\ Sections.&Local\ Function\ Def\. \:call C_CommentSection("FUNCTION DEFINITIONS - LOCAL TO THIS SOURCE FILE")0i amenu &Comments.&C-File\ Sections.-SEP6- : amenu &Comments.&C-File\ Sections.Local\ &Class\ Def\. \:call C_CommentSection("CLASS DEFINITIONS - LOCAL TO THIS SOURCE FILE")0i amenu &Comments.&C-File\ Sections.E&xp\.\ Class\ Impl\. \:call C_CommentSection("CLASS IMPLEMENTATIONS - EXPORTED CLASSES")0i amenu &Comments.&C-File\ Sections.Local\ Class\ Im&pl\. \:call C_CommentSection("CLASS IMPLEMENTATIONS - LOCAL CLASSES")0i amenu &Comments.&C-File\ Sections.-SEP7- : amenu &Comments.&C-File\ Sections.&All\ Sections,\ C \:call C_Comment_C_SectionAll1()0i amenu &Comments.&C-File\ Sections.All\ &Sections,\ C++ \:call C_Comment_C_SectionAll2()0i " amenu &Comments.-SEP8- : " "----- Submenu : C-Comments : keyword comments ---------------------------------------------------------- " amenu &Comments.&KEYWORD+Comm\..\/\/\ \:&BUG\: $:call C_CommentClassified("BUG") kgJA amenu &Comments.&KEYWORD+Comm\..\/\/\ \:&COMPILER\: $:call C_CommentClassified("COMPILER")kgJA amenu &Comments.&KEYWORD+Comm\..\/\/\ \:&TODO\: $:call C_CommentClassified("TODO") kgJA amenu &Comments.&KEYWORD+Comm\..\/\/\ \:T&RICKY\: $:call C_CommentClassified("TRICKY") kgJA amenu &Comments.&KEYWORD+Comm\..\/\/\ \:&WARNING\: $:call C_CommentClassified("WARNING") kgJA amenu &Comments.&KEYWORD+Comm\..\/\/\ \:&new\ keyword\: $:call C_CommentClassified("") kgJf:a " "----- Submenu : C-Comments : keyword comments ---------------------------------------------------------- " amenu &Comments.spec&ial\ Comm\..\/\/\ &EMPTY A// EMPTY amenu &Comments.spec&ial\ Comm\..\/\/\ FALL\ TH&ROUGH A// FALL THROUGH amenu &Comments.spec&ial\ Comm\..\/\/\ &IMPL\.\ TYPE\ CONV A// IMPLICIT TYPE CONVERSION amenu &Comments.spec&ial\ Comm\..\/\/\ &NOT\ REACHED A// NOT REACHED amenu &Comments.spec&ial\ Comm\..\/\/\ TO\ &BE\ IMPL\. A// REMAINS TO BE IMPLEMENTED " amenu &Comments.-SEP9- : amenu &Comments.&Date :let @z=strftime("%x") "zpa amenu &Comments.Date\ &Time :let @z=strftime("%x - %X")"zpa amenu &Comments.-SEP10- : vmenu &Comments.code&->comment :'<,'>s/^/\/\//:nohlsearch vmenu &Comments.c&omment->code :'<,'>s/^\/\///:nohlsearch " " "=============================================================================================== "----- Menu : C-Statements --------------------------------------------------------------------- "=============================================================================================== " imenu C-St&atements.&if :let @z="if ( )\n\t\n" "z]pf(la imenu C-St&atements.if\ &else :let @z="if ( )\n\t\nelse\n\t\n" "z]pf(la imenu C-St&atements.i&f\ \{\ \} :let @z="if ( )\n{\n\t\n}\n" "z]pf(la imenu C-St&atements.if\ \{\ \}\ e&lse\ \{\ \} :let @z="if ( )\n{\n\t\n}\nelse\n{\n\t\n}\n" "z]pf(la imenu C-St&atements.f&or :let @z="for ( ; ; )\n" "z]pf;i imenu C-St&atements.fo&r\ \{\ \} :let @z="for ( ; ; )\n{\n\t\n}\n" "z]pf;i imenu C-St&atements.&while\ \{\ \} :let @z="while ( )\n{\n\t\n}\n" "z]pf(la imenu C-St&atements.&do\ \{\ \}\ while :call C_DoWhile() "z]p:/while f(la imenu C-St&atements.&switch :call C_CodeSwitch() "z]pf(la imenu C-St&atements.&case :call C_CodeCase() "z]pf:i imenu C-St&atements.&\{\ \} :let @z="{\n\t\n}\n" "z]pjA imenu C-St&atements.-SEP1- : imenu C-St&atements.#include\ &\<\.\.\.\> :let @z="#include\t<.h>" "zpF.i imenu C-St&atements.#include\ \"\.\.\.\" :let @z="#include\t\".h\"" "zpF.i imenu C-St&atements.&#define :let @z="#define\t\t\t\t// ""zp4Fa imenu C-St&atements.#if\.\.#else\.\.#endif :call C_PPIfElse('if') ji imenu C-St&atements.#ifdef\.\.#else\.\.#endif :call C_PPIfElse('ifdef') ji imenu C-St&atements.#ifndef\.\.#else\.\.#endif :call C_PPIfElse('ifndef') ji imenu C-St&atements.#ifndef\.\.#def\.\.#endif :call C_PPIfDef() 2ji " "=============================================================================================== "----- Menu : C-Idioms ------------------------------------------------------------------------- "=============================================================================================== " imenu C-&Idioms.&function :call C_CodeFunction() imenu C-&Idioms.&main :call C_CodeMain()3jA imenu C-&Idioms.-SEP1- : imenu C-&Idioms.for\ (\ i=&0;\ \ \ i0fni imenu C-&Idioms.for\ (\ i=n&-1;\ i>=0;\ i\-=1\ ) for ( i=n-1; i>=0; i-=1 )0fni imenu C-&Idioms.for\ (\ i=&1;\ \ \ i<=n;\ i\+=1\ ) for ( i=1; i<=n; i+=1 )0fni imenu C-&Idioms.for\ (\ i=&n;\ \ \ i>=1;\ i\-=1\ ) for ( i=n; i>=1; i-=1 )0fni imenu C-&Idioms.-SEP2- : imenu C-&Idioms.&enum\+typedef :call C_EST("enum")2jA imenu C-&Idioms.&struct\+typedef :call C_EST("struct")2jA imenu C-&Idioms.&union\+typedef :call C_EST("union")2jA imenu C-&Idioms.-SEP3- : imenu C-&Idioms.&printf printf ("\n");F\i imenu C-&Idioms.s&canf scanf ("", & );F"i " "----- Submenu : C-Idioms: standard library ------------------------------------------------------- " imenu C-&Idioms.&#include\ Std\.Lib\..\<&assert\.h\> o#include imenu C-&Idioms.&#include\ Std\.Lib\..\<&ctype\.h\> o#include imenu C-&Idioms.&#include\ Std\.Lib\..\<&errno\.h\> o#include imenu C-&Idioms.&#include\ Std\.Lib\..\<&float\.h\> o#include imenu C-&Idioms.&#include\ Std\.Lib\..\<&limits\.h\> o#include imenu C-&Idioms.&#include\ Std\.Lib\..\ o#include imenu C-&Idioms.&#include\ Std\.Lib\..\<&math\.h\> o#include imenu C-&Idioms.&#include\ Std\.Lib\..\ o#include imenu C-&Idioms.&#include\ Std\.Lib\..\ o#include imenu C-&Idioms.&#include\ Std\.Lib\..\ o#include imenu C-&Idioms.&#include\ Std\.Lib\..\ o#include imenu C-&Idioms.&#include\ Std\.Lib\..\<&stdio\.h\> o#include imenu C-&Idioms.&#include\ Std\.Lib\..\ o#include imenu C-&Idioms.&#include\ Std\.Lib\..\ o#include imenu C-&Idioms.&#include\ Std\.Lib\..\<&time\.h\> o#include " imenu C-&Idioms.-SEP4- : imenu C-&Idioms.p=m&alloc\(\ \) :call C_CodeMalloc()f(la imenu C-&Idioms.open\ &input\ file :call C_CodeFopenRead()jf"a imenu C-&Idioms.open\ &output\ file :call C_CodeFopenWrite()jf"a if s:C_CodeSnippets != "" amenu C-&Idioms.-SEP5- : amenu C-&Idioms.read\ code\ snippet :call C_CodeSnippet("r") amenu C-&Idioms.write\ code\ snippet :call C_CodeSnippet("w") vmenu C-&Idioms.write\ code\ snippet :call C_CodeSnippet("wv") amenu C-&Idioms.edit\ code\ snippet :call C_CodeSnippet("e") endif imenu C-&Idioms.-SEP6- : "=============================================================================================== "----- Menu : C++ ------------------------------------------------------------------------------ "=============================================================================================== " imenu C&++.c&in cin>> ;i imenu C&++.cout\ &variable cout<< << endl;2F<< "\n";F\i " "----- Submenu : C++ : output manipulators ------------------------------------------------------- " imenu C&++.output\ mani&pulators.\<\<\ &endl << endl a imenu C&++.output\ mani&pulators.\<\<\ &flush << flush a imenu C&++.output\ mani&pulators.\<\<\ &dec << dec a imenu C&++.output\ mani&pulators.\<\<\ &hex << hex a imenu C&++.output\ mani&pulators.\<\<\ &oct << oct a imenu C&++.output\ mani&pulators.\<\<\ set&base\(\ \) << setbase() F)i imenu C&++.output\ mani&pulators.\<\<\ setfi&ll\(\ \) << setfill() F)i imenu C&++.output\ mani&pulators.\<\<\ set&iosflag\(\ \) << setiosflags() F)i imenu C&++.output\ mani&pulators.\<\<\ &resetiosflag\(\ \) << resetiosflags() F)i imenu C&++.output\ mani&pulators.\<\<\ set&precision\(\ \) << setprecision() F)i imenu C&++.output\ mani&pulators.\<\<\ set&w\(\ \) << setw() F)i imenu C&++.output\ mani&pulators.&#include\ \ :let @z="#include\t" "z]pa " "----- Submenu : C++ : ios flag bits ------------------------------------------------------------- " imenu C&++.ios\ fla&gbits.ios::&skipws ios::skipwsa imenu C&++.ios\ fla&gbits.ios::&left ios::lefta imenu C&++.ios\ fla&gbits.ios::&right ios::righta imenu C&++.ios\ fla&gbits.ios::&internal ios::internala imenu C&++.ios\ fla&gbits.ios::&boolalpha ios::boolalphaa imenu C&++.ios\ fla&gbits.ios::&dec ios::deca imenu C&++.ios\ fla&gbits.ios::&hex ios::hexa imenu C&++.ios\ fla&gbits.ios::&oct ios::octa imenu C&++.ios\ fla&gbits.ios::s&cientific ios::scientifica imenu C&++.ios\ fla&gbits.ios::&fixed ios::fixeda imenu C&++.ios\ fla&gbits.ios::sho&wbase ios::showbasea imenu C&++.ios\ fla&gbits.ios::show&pos ios::showposa imenu C&++.ios\ fla&gbits.ios::&uppercase ios::uppercasea imenu C&++.ios\ fla&gbits.ios::&adjustfield ios::adjustfielda imenu C&++.ios\ fla&gbits.ios::bas&efield ios::basefielda imenu C&++.ios\ fla&gbits.ios::floa&tfield ios::floatfielda imenu C&++.ios\ fla&gbits.ios::u&nitbuf ios::unitbufa " imenu C&++.c&err\ string cerr<< "\n";F\i imenu C&++.&#include\ \ :let @z="#include\t" "z]pa imenu C&++.-SEP2- : imenu C&++.&method\ implementaton :call C_CodeMethod() imenu C&++.&class :call C_CodeClass() imenu C&++.class\ using\ &new :call C_CodeClassNew() imenu C&++.err&or\ class :call C_CodeErrorClass()3jf"a imenu C&++.-SEP3- : imenu C&++.&template\ class :call C_CodeTemplateClass() imenu C&++.template\ class\ using\ ne&w :call C_CodeTemplateClassNew() imenu C&++.template\ &function :call C_CodeTemplateFunct() imenu C&++.-SEP4- : imenu C&++.friend\ operator\ << :call C_CodeOutputOperator()3jf.a imenu C&++.friend\ operator\ >> :call C_CodeInputOperator()3jf.a imenu C&++.-SEP5- : imenu C&++.tr&y\ \.\.\ catch :call C_CodeTryCatch()4j2f a imenu C&++.c&atch :call C_CodeCatch()2f a imenu C&++.catch\(\.\.\.\) :let @z="catch (...)\n{\n\t\n}""z]p2ja imenu C&++.-SEP6- : imenu C&++.open\ input\ file :call C_CodeIfstream()f"a imenu C&++.open\ output\ file :call C_CodeOfstream()f"a imenu C&++.-SEP7- : imenu C&++.&using\ namespace using namespace ;$i imenu C&++.namespace :let @z="namespace \n{\n\n}" "z]pA imenu C&++.-SEP8- : " "----- Submenu : RTTI ---------------------------------------------------------------------------- " imenu C&++.&RTTI.&typeid typeid()F(a imenu C&++.&RTTI.&static_cast static_cast<>()F()F()F()F:call C_CodeExternC()2jf.i " "=============================================================================================== "----- Menu : run ----------------------------------------------------------------------------- "=============================================================================================== " amenu C-&Run.save\ and\ &compile\ \ \\ :call C_Compile() amenu C-&Run.&link\ \ \ :call C_Link() amenu C-&Run.&run\ \ \\ :call C_Run(0) if s:C_Pager != "" amenu C-&Run.run\ with\ &pager :call C_Run(1) endif amenu C-&Run.command\ line\ &arguments :call C_Arguments() amenu C-&Run.&make\ \ \\ :call C_Make() amenu C-&Run.command\ line\ ar&guments\ for\ make :call C_MakeArguments() imenu C-&Run.-SEP1- : amenu C-&Run.har&dcopy\ buffer\ to\ FILENAME\.ps :call C_Hardcopy("n") vmenu C-&Run.hardcop&y\ highlighted\ part\ to\ FILENAME\.part\.ps :call C_Hardcopy("v") imenu C-&Run.-SEP2- : amenu C-&Run.&settings :call C_Settings() endfunction " "=============================================================================================== "----- Menu Functions -------------------------------------------------------------------------- "=============================================================================================== " "------------------------------------------------------------------------------ " C-Comments : frame comment "------------------------------------------------------------------------------ function! C_CommentFrame () let @z= "//----------------------------------------------------------------------\n" let @z=@z."// \n" let @z=@z."//----------------------------------------------------------------------\n" put z endfunction " "------------------------------------------------------------------------------ " C-Comments : function "------------------------------------------------------------------------------ function! C_CommentFunction () let @z= "//#=== FUNCTION ======================================================================\n" let @z= @z."//#\n" let @z= @z."//# Name: \n" let @z= @z."//#\n" let @z= @z."//# Description: \n" let @z= @z."//#\n" let @z= @z."//#- PARAMETER -------------------------------------------------------------------------\n" let @z= @z."//# Mode Type Name Description\n" let @z= @z."//#-------------------------------------------------------------------------------------\n" let @z= @z."//# in: \n" let @z= @z."//# in-out: \n" let @z= @z."//# out: \n" let @z= @z."//# return: \n" let @z= @z."//#-------------------------------------------------------------------------------------\n" let @z= @z."//# Author: ".s:C_AuthorName."\n" let @z= @z."//# Created: ".strftime("%x")."\n" let @z= @z."//# Revision: none\n" let @z= @z."//#=====================================================================================\n" put z endfunction " "------------------------------------------------------------------------------ " C-Comments : main "------------------------------------------------------------------------------ function! C_CommentMain () let @z= "//#=== FUNCTION MAIN =================================================================\n" let @z= @z."//#\n" let @z= @z."//# Description: \n" let @z= @z."//#\n" let @z= @z."//#\n" let @z= @z."//#- PARAMETER -------------------------------------------------------------------------\n" let @z= @z."//# Mode Type Name Description\n" let @z= @z."//#-------------------------------------------------------------------------------------\n" let @z= @z."//# in: int argc number of command line arguments\n" let @z= @z."//# in: char* argv[] pointers to command line arguments\n" let @z= @z."//# in: char* argv[0] name of the command\n" let @z= @z."//# return: int --- return code\n" let @z= @z."//#-------------------------------------------------------------------------------------\n" let @z= @z."//# Author: ".s:C_AuthorName."\n" let @z= @z."//# Created: ".strftime("%x")."\n" let @z= @z."//# Revision: none\n" let @z= @z."//#=====================================================================================\n" put z endfunction " "------------------------------------------------------------------------------ " C-Comments : file prologue "------------------------------------------------------------------------------ function! C_CommentFilePrologue () let @z= "//#=====================================================================================" let @z= @z."\n//#" let @z= @z."\n//# Filename: ".expand("%:t") let @z= @z."\n//#" let @z= @z."\n//# Description: " let @z= @z."\n//#" " let @z= @z."\n//# Usage: ./".expand("%:t:r").".e " " let @z= @z."\n//#" let @z= @z."\n//# Version: 1.0" let @z= @z."\n//# Created: ".strftime("%x") let @z= @z."\n//# Revision: none" if(s:C_CCompiler!="") let @z= @z."\n//# Compiler: ".s:C_CCompiler." / ".s:C_CplusCompiler endif let @z= @z."\n//#" let @z= @z."\n//# Author: ".s:C_AuthorName if(s:C_AuthorRef!="") let @z= @z." (".s:C_AuthorRef.")" endif if(s:C_Company!="") let @z= @z."\n//# Company: ".s:C_Company endif if(s:C_Email!="") let @z= @z."\n//# Email: ".s:C_Email endif if(s:C_CopyrightHolder!="") let @z= @z. "\n//# Copyright: Copyright (C) ". s:C_CopyrightYears." ".s:C_CopyrightHolder endif if(s:C_Project!="") let @z= @z."\n//#" let @z= @z."\n//# Project: ".s:C_Project endif let @z= @z."\n//#" let @z= @z."\n//#=====================================================================================\n\n" put! z endfunction " "------------------------------------------------------------------------------ " C-Comments : classified comments "------------------------------------------------------------------------------ function! C_CommentClassified (class) put = ' // :'.a:class.':'.strftime(\"%x\").':'.s:C_AuthorRef.': ' endfunction " "------------------------------------------------------------------------------ " C-Comments : Section Comments "------------------------------------------------------------------------------ " function! C_CommentSection (keyword) let @z= "// ##### ".a:keyword." " let n = 74-strlen(a:keyword) while n>0 let @z = @z."#" let n = n-1 endwhile let @z= @z."\n\n" put z | +1 endfunction " "------------------------------------------------------------------------------ " C-Comments : Section Comments "------------------------------------------------------------------------------ " function! C_Comment_C_SectionAll1 () call C_CommentSection("HEADER FILE INCLUDES") call C_CommentSection("MACROS - LOCAL TO THIS SOURCE FILE") call C_CommentSection("DATA TYPES - LOCAL TO THIS SOURCE FILE") call C_CommentSection("TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE") call C_CommentSection("VARIABLES - LOCAL TO THIS SOURCE FILE") call C_CommentSection("PROTOTYPES - LOCAL TO THIS SOURCE FILE") call C_CommentSection("FUNCTION DEFINITIONS - EXPORTED FUNCTIONS") call C_CommentSection("FUNCTION DEFINITIONS - LOCAL TO THIS SOURCE FILE") endfunction " function! C_Comment_C_SectionAll2 () call C_Comment_C_SectionAll1() call C_CommentSection("CLASS DEFINITIONS - LOCAL TO THIS SOURCE FILE") call C_CommentSection("CLASS IMPLEMENTATIONS - EXPORTED CLASSES") call C_CommentSection("CLASS IMPLEMENTATIONS - LOCAL CLASSES") endfunction " function! C_Comment_H_SectionAll1 () call C_CommentSection("HEADER FILE INCLUDES") call C_CommentSection("EXPORTED MACROS") call C_CommentSection("EXPORTED DATA TYPES") call C_CommentSection("EXPORTED TYPE DEFINITIONS") call C_CommentSection("EXPORTED VARIABLES") call C_CommentSection("EXPORTED FUNCTION DECLARATIONS") endfunction " function! C_Comment_H_SectionAll2 () call C_Comment_H_SectionAll1() call C_CommentSection("EXPORTED CLASS DEFINITIONS") endfunction " "===================================================================================== "----- Menu : Statements ----------------------------------------------------------- "===================================================================================== " "------------------------------------------------------------------------------ " Statements : do-while "------------------------------------------------------------------------------ " function! C_DoWhile () let @z= "do\n{\n\t\n}\nwhile ( );" let @z= @z."\t\t\t\t// ----- end do-while -----\n" endfunction " "------------------------------------------------------------------------------ " Statements : switch " Statements : case "------------------------------------------------------------------------------ " let s:C_CaseStatement = "\tcase :\t\n\t\tbreak;\n\n" " function! C_CodeSwitch () let @z= "switch ( )\n{\n\n" let loopcount=4 " default number of cases while loopcount>0 let @z= @z.s:C_CaseStatement let loopcount=loopcount-1 endwhile let @z= @z."\tdefault:\t\n\t\tbreak;\n}" let @z= @z."\t\t\t\t// ----- end switch -----\n" endfunction " function! C_CodeCase () let @z= s:C_CaseStatement endfunction " "------------------------------------------------------------------------------ " Statements : #if .. #else .. #endif " Statements : #ifdef .. #else .. #endif " Statements : #ifndef .. #else .. #endif "------------------------------------------------------------------------------ function! C_PPIfElse (keyword) let defaultcond = "CONDITION" let identifier=inputdialog("(uppercase) condition for #".a:keyword, defaultcond ) if identifier != "" let @z= "#".a:keyword." ".identifier."\n\n\n" let @z= @z."#else // ----- #".a:keyword." ".identifier." -----\n\n\n" let @z= @z."#endif // ----- #".a:keyword." ".identifier." -----\n" put z endif endfunction " "------------------------------------------------------------------------------ " Statements : #ifndef .. #define .. #endif "------------------------------------------------------------------------------ function! C_PPIfDef () " use filename without path (:t) and extension (:r) : let defaultcond = toupper(expand("%:t:r"))."_INC" let identifier=inputdialog("(uppercase) condition for #ifndef", defaultcond ) if identifier != "" let @z= "#ifndef ".identifier."\n" let @z= @z."#define ".identifier."\n\n\n" let @z= @z."#endif // ----- #ifndef ".identifier." -----\n" put z endif endfunction " "------------------------------------------------------------------------------ " C-Idioms : for( i=0; i0 let tabs = tabs."\t" let n = n-1 endwhile let @z= "class ".s:C_ClassName let @z= @z."\n{\n\n\tpublic:\n\n" let @z= @z."\t\t// ==================== LIFECYCLE =========================================\n\n" let @z= @z."\t\t".s:C_ClassName." ();\t\t\t\t\t\t\t".tabs."// constructor\n" let @z= @z."\t\t".s:C_ClassName." (const ".s:C_ClassName." &obj);\t// copy constructor\n" let @z= @z."\t\t~".s:C_ClassName." (); \t\t\t\t\t\t".tabs."// destructor\n\n" let @z= @z."\t\t// ==================== OPERATORS =========================================\n\n" let @z= @z."\t\tconst ".s:C_ClassName."& operator = (const ".s:C_ClassName." &obj);" let @z= @z."\t\t// assignemnt operator\n\n" let @z= @z."\t\t// ==================== OPERATIONS =========================================\n\n" let @z= @z."\t\t// ==================== ACCESS =========================================\n\n" let @z= @z."\t\t// ==================== INQUIRY =========================================\n\n" let @z= @z."\t\t// ==================== NESTED ERROR CLASSES ===============================\n\n\n" let @z= @z."\tprotected:\n\n" let @z= @z."\tprivate:\n\n" let @z= @z."\n};\t\t\t// ---------- end of class ".s:C_ClassName." ----------\n" let @z= @z."\n\n".s:C_ClassName."::".s:C_ClassName." ()\n{\n}" let @z= @z."\t\t\t\t// ---------- end of method ".s:C_ClassName."::".s:C_ClassName." (constructor) ----------\n" let @z= @z."\n\n".s:C_ClassName."::".s:C_ClassName." (const ".s:C_ClassName." &obj)\n{\n}" let @z= @z."\t\t\t\t// ---------- end of method ".s:C_ClassName."::".s:C_ClassName." (copy constructor) ----------\n" let @z= @z."\n\n".s:C_ClassName."::~".s:C_ClassName." ()\n{\n}" let @z= @z."\t\t\t\t// ---------- end of method ".s:C_ClassName."::~".s:C_ClassName." (destructor) ----------\n" let @z= @z."\n\nconst ".s:C_ClassName."&\n".s:C_ClassName."::operator = (const ".s:C_ClassName." &obj)" let @z= @z."\n{\n\tif(this!=&obj)\n\t{\n\n\t}\n\treturn *this;\n}" let @z= @z."\t\t\t\t// ---------- end of method ".s:C_ClassName."::operator = (assignment operator) ----------\n" put z endif endfunction " "------------------------------------------------------------------------------ " C++ : simple error class "------------------------------------------------------------------------------ function! C_CodeErrorClass() let classname=inputdialog("name of error class", "Error" ) if classname != "" let @z= "class ".classname let @z= @z."\n{\n\tprotected:\tchar *message;" let @z= @z."\n\tpublic:\t\t\t".classname." (char *msg) { message=msg; }" let @z= @z."\n\t\t\t\t\t\t\tvirtual const char* what () const throw () { return message; }" let @z= @z."\n};\t\t\t// ---------- end of class ".classname." ----------\n" put z endif endfunction " " "------------------------------------------------------------------------------ " C++ : template class "------------------------------------------------------------------------------ function! C_CodeTemplateClass () let classname=inputdialog("name of template class", "TCls" ) if classname != "" let @z= "template < class T >\nclass ".classname let @z= @z."\n{\n\n\tpublic:\n\n" let @z= @z."\t\t// ==================== LIFECYCLE =========================================\n\n" let @z= @z."\t\t".classname." (); \t// constructor\n\n" let @z= @z."\t\t// Use compiler-generated copy constructor, assignment operator and destructor\n\n" let @z= @z."\t\t// ==================== OPERATORS =========================================\n\n" let @z= @z."\t\t// ==================== OPERATIONS =========================================\n\n" let @z= @z."\t\t// ==================== ACCESS =========================================\n\n" let @z= @z."\t\t// ==================== INQUIRY =========================================\n\n" let @z= @z."\t\t// ==================== NESTED ERROR CLASSES ===============================\n\n\n" let @z= @z."\tprotected:\n\n" let @z= @z."\tprivate:\n\n" let @z= @z."\n};\t\t\t// ---------- end of template class ".classname." ----------\n" let @z= @z."\n\ntemplate < class T >" let @z= @z."\n".classname." < T >:: ".classname." ()\n{\n}" let @z= @z."\t\t\t\t// ---------- end of constructor of template class ".classname." ----------\n" put z endif endfunction " "------------------------------------------------------------------------------ " C++ : template class using the new operator "------------------------------------------------------------------------------ function! C_CodeTemplateClassNew () let classname=inputdialog("name of template class using new", "TClsN" ) if classname != "" let tabs = "" let n = (strlen(classname)-1)/2 " number of extra tabs while n>0 let tabs = tabs."\t" let n = n-1 endwhile let @z= "template < class T >\nclass ".classname let @z= @z."\n{\n\n\tpublic:\n\n" let @z= @z."\t\t// ==================== LIFECYCLE =========================================\n\n" let @z= @z."\t\t".classname." ();\t\t\t\t\t\t\t".tabs."// constructor\n" let @z= @z."\t\t".classname." (const ".classname." &obj);\t// copy constructor\n" let @z= @z."\t\t~".classname." (); \t\t\t\t\t\t".tabs."// destructor\n\n" let @z= @z."\t\t// ==================== OPERATORS =========================================\n\n" let @z= @z."\t\tconst ".classname."& operator = (const ".classname." &obj);" let @z= @z."\t\t// assignment operator\n\n" let @z= @z."\t\t// ==================== OPERATIONS =========================================\n\n" let @z= @z."\t\t// ==================== ACCESS =========================================\n\n" let @z= @z."\t\t// ==================== INQUIRY =========================================\n\n" let @z= @z."\t\t// ==================== NESTED ERROR CLASSES ===============================\n\n\n" let @z= @z."\tprotected:\n\n" let @z= @z."\tprivate:\n\n" let @z= @z."\n};\t\t\t// ---------- end of template class ".classname." ----------\n" let @z= @z."\n\ntemplate < class T >" let @z= @z."\n".classname."< T >::".classname." ()\n{\n}" let @z= @z."\t\t\t\t// ---------- end of constructor of template class ".classname." ----------\n" let @z= @z."\n\ntemplate < class T >" let @z= @z."\n".classname."< T >::".classname." (const ".classname." &obj)\n{\n}" let @z= @z."\t\t\t\t// ---------- end of copy constructor of template class ".classname." ----------\n" let @z= @z."\n\ntemplate < class T >" let @z= @z."\n".classname."< T >::~".classname." ()\n{\n}" let @z= @z."\t\t\t\t// ---------- end of destructor of template class ".classname." ----------\n" let @z= @z."\n\ntemplate < class T >" let @z= @z."\nconst ".classname."< T >& ".classname."< T >::operator = (const ".classname." &obj)" let @z= @z."\n{\n\tif(this!=&obj)\n\t{\n\n\t}\n\treturn *this;\n}" let @z= @z."\t\t\t\t// ---------- end of assignment operator of template class ".classname." ----------\n" put z endif endfunction " "------------------------------------------------------------------------------ " C++ : template function "------------------------------------------------------------------------------ function! C_CodeTemplateFunct () let identifier=inputdialog("template function name", "f" ) if identifier != "" let @z= "template void\n".identifier."\t( T param )\n{\n\n\n\treturn ;\n}" let @z= @z."\t\t\t\t// ---------- end of template function ".identifier." ----------" put z endif endfunction " "------------------------------------------------------------------------------ " C-Idioms : enum struct union "------------------------------------------------------------------------------ function! C_EST (su) let name= strpart( a:su, 0, 1 ) " first character of argument let name= inputdialog("(lowercase) ".a:su." name", name ) if name != "" " let typename = substitute(name,".*", '\u\0', "" ) " first character to uppercase let typename = name let @z= a:su." ".name."\n{\n\t\n};" let @z= @z."\t\t\t\t// ---------- end of ".a:su." ".name." ----------\n\n" let @z= @z."typedef ".a:su." ".name." ".typename.";\n\n" put z endif endfunction " "------------------------------------------------------------------------------ " C-Idioms : malloc "------------------------------------------------------------------------------ function! C_CodeMalloc () let pointername= inputdialog("pointer name", "p") if pointername != "" let @z= pointername."\t= malloc ( );" let @z= @z."\n\nif (".pointername."==NULL)\n{" let @z= @z."\n\tfprintf (stderr, \"\\n ** dynamic memory allocation failed ** exit **\\n\" );" let @z= @z."\n\texit(3);\n}" let @z= @z."\n\nfree (".pointername.");\n\n" put z endif endfunction " "------------------------------------------------------------------------------ " C-Idioms : open file for reading "------------------------------------------------------------------------------ function! C_CodeFopenRead () let filepointer=inputdialog("input-file pointer", "infile") if filepointer != "" let filename=filepointer."_file_name" let @z= "FILE\t*".filepointer.";\t\t\t\t\t\t\t\t\t// input-file pointer\n" let @z= @z."char\t*".filename." = \"\";\t\t// input-file name\n\n" let @z= @z.filepointer."\t= fopen ( ".filename.", \"r\" );\n" let @z= @z."if (".filepointer." == NULL)\n{\n" let @z= @z."\tfprintf (stderr, \" ** cannot open input file %s ** exit **\\n\", ".filename." );\n" let @z= @z."\texit (1);\n}\n\n\n" let @z= @z."fclose ( ".filepointer." );\t\t\t\t\t\t\t// close input file\n" put z exe ":imenu C-&Idioms.fscanf(".filepointer.",\\ \"\",\\ ); fscanf( ".filepointer.", \"\", & );F\"i" endif endfunction " "------------------------------------------------------------------------------ " C-Idioms : open file for writing "------------------------------------------------------------------------------ function! C_CodeFopenWrite () let filepointer=inputdialog("output-file pointer", "outfile") if filepointer != "" let filename=filepointer."_file_name" let @z= "FILE\t*".filepointer.";\t\t\t\t\t\t\t\t\t// output-file pointer\n" let @z= @z."char\t*".filename." = \"\";\t// output-file name\n\n" let @z= @z.filepointer."\t= fopen ( ".filename.", \"w\" );\n" let @z= @z."if (".filepointer." == NULL)\n{\n" let @z= @z."\tfprintf (stderr, \" ** cannot open output file %s ** exit **\\n\", ".filename." );\n" let @z= @z."\texit (2);\n}\n\n\n" let @z= @z."fclose ( ".filepointer." );\t\t\t\t\t\t\t// close output file\n" put z exe ":imenu C-&Idioms.fprintf(".filepointer.",\\ \"\\\\n\",\\ ); fprintf( ".filepointer.", \"\\n\", );F\\i" endif endfunction " "------------------------------------------------------------------------------ " C++ : open file for reading "------------------------------------------------------------------------------ function! C_CodeIfstream () let ifstreamobject=inputdialog("ifstream object", "ifs" ) if ifstreamobject != "" let filename=ifstreamobject."_file_name" let @z= "char *".filename." = \"\";\t\t// input file name\n" let @z= @z."ifstream\t".ifstreamobject.";\t\t\t\t\t\t\t// create ifstream object\n\n" let @z= @z.ifstreamobject.".open(".filename.");\t\t// open ifstream\n" let @z= @z."if (!".ifstreamobject.")\n{\n" let @z= @z."\tcerr << \"\\nERROR : failed to open input file \" << ".filename." << \" --- exit program\\n\";\n" let @z= @z."\texit (1);\n}\n\n\n" let @z= @z.ifstreamobject.".close();\t\t// close ifstream\n" put z endif endfunction " "------------------------------------------------------------------------------ " C++ : open file for writing "------------------------------------------------------------------------------ function! C_CodeOfstream () let ofstreamobject=inputdialog("ofstream object", "ofs" ) if ofstreamobject != "" let filename=ofstreamobject."_file_name" let @z= "char *".filename." = \"\";\t\t// output file name\n" let @z= @z."ofstream\t".ofstreamobject.";\t\t\t\t\t\t\t// create ofstream object\n\n" let @z= @z.ofstreamobject.".open(".filename.");\t\t// open ofstream\n" let @z= @z."if (!".ofstreamobject.")\n{\n" let @z= @z."\tcerr << \"\\nERROR : failed to open output file \" << ".filename." << \" --- exit program\\n\";\n" let @z= @z."\texit (2);\n}\n\n\n" let @z= @z.ofstreamobject.".close();\t\t// close ofstream\n" put z endif endfunction " "------------------------------------------------------------------------------ " C++ : extern "C" "------------------------------------------------------------------------------ function! C_CodeExternC() let @z= "extern \"C\"\n{\n\t#include\t\".h\"\n}" put z endfunction " "------------------------------------------------------------------------------ " C++ : output operator "------------------------------------------------------------------------------ function! C_CodeOutputOperator () let identifier=inputdialog("class name", s:C_ClassName ) if identifier != "" let @z= "friend ostream &\noperator << (ostream & os, const ".identifier." & obj )\n" let @z= @z."{\n\tos << obj. ;\n\treturn os;\n}" let @z= @z."\t\t\t\t// ---------- class ".identifier." : end of friend function operator << ----------" put z endif endfunction " "------------------------------------------------------------------------------ " C++ : input operator "------------------------------------------------------------------------------ function! C_CodeInputOperator () let identifier=inputdialog("class name", s:C_ClassName ) if identifier != "" let @z= "friend istream &\noperator >> (istream & is, ".identifier." & obj )" let @z= @z."\n{\n\tis >> obj. ;\n\treturn is;\n}" let @z= @z."\t\t\t\t// ---------- class ".identifier." : end of friend function operator >> ----------" put z endif endfunction " " "------------------------------------------------------------------------------ " C++ : try catch "------------------------------------------------------------------------------ function! C_CodeTryCatch () let @z= "try\n{\n\t\n}\n" let @z= @z."catch (const &ExceptObj)\t\t// handle exception: \n{\n\t\n}\n" let @z= @z."catch (...)\t\t\t// handle exception: unspezified\n{\n\t\n}" put z endfunction " "------------------------------------------------------------------------------ " C++ : catch "------------------------------------------------------------------------------ function! C_CodeCatch () let @z= "catch (const &ExceptObj)\t\t// handle exception: \n{\n\t\n}\n" put z endfunction " "------------------------------------------------------------------------------ " run : C_Compile "------------------------------------------------------------------------------ " The standard make program 'make' called by vim is set to the C or C++ compiler " and reset after the compilation (set makeprg=... ). " The errorfile created by the compiler will now be read by gvim and " the commands cl, cp, cn, ... can be used. " " "------------------------------------------------------------------------------ function! C_Compile () let Sou = expand("%") " name of the file in the current buffer let Obj = expand("%:r").".o" " name of the object let Ext = expand("%:e") " file extension " update : write source file if necessary exe ":update" " compilation if object does not exist or object exists and is older then the source if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou))) if Ext == s:C_CExtension exe "set makeprg=".s:C_CCompiler else exe "set makeprg=".s:C_CplusCompiler endif " " COMPILATION exe "make ".s:C_CFlags." ".Sou." -o ".Obj exe "set makeprg=make" " " open error window if necessary exe ":cwindow" endif endfunction " "------------------------------------------------------------------------------ " run : C_Link "------------------------------------------------------------------------------ " The standard make program which is used by gvim is set to the compiler " (for linking) and reset after linking. " " calls: C_Compile "------------------------------------------------------------------------------ function! C_Link () call C_Compile() let Sou = expand("%") " name of the file in the current buffer let Obj = expand("%:r").".o" " name of the object file let Exe = expand("%:r").".e" " name of the executable let Ext = expand("%:e") " file extension " no linkage if: " executable exists " object exists " source exists " executable newer then object " object newer then source if filereadable(Exe) && \ filereadable(Obj) && \ filereadable(Sou) && \ (getftime(Exe) >= getftime(Obj)) && \ (getftime(Obj) >= getftime(Sou)) return endif " linkage if: " object exists " source exists " object newer then source if filereadable(Obj) && (getftime(Obj) >= getftime(Sou)) if Ext == s:C_CExtension exe "set makeprg=".s:C_CCompiler else exe "set makeprg=".s:C_CplusCompiler endif exe "make ".s:C_LFlags." ".s:C_Libs." -o ".Exe." ".Obj exe "set makeprg=make" endif endfunction " "------------------------------------------------------------------------------ " run : C_Run " " calls: C_Link "------------------------------------------------------------------------------ function! C_Run (arg1) let Sou = expand("%") " name of the source file let Obj = expand("%:r").".o" " name of the object file let Exe = expand("%:r").".e" " name of the executable call C_Link() " compile+link the file in the current buffer " exe exists and is newer then the object, the object is newer then the source " this prevents an old executable from running in the case of compilation or link errors if filereadable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou) if a:arg1==0 exe "!./".Exe." ".s:C_ExeCmdLineArgs else exe "!./".Exe." ".s:C_ExeCmdLineArgs." | ".s:C_Pager endif endif endfunction " "------------------------------------------------------------------------------ " run : Arguments for the executable "------------------------------------------------------------------------------ function! C_Arguments () let s:C_ExeCmdLineArgs= inputdialog("command line arguments",s:C_ExeCmdLineArgs) endfunction " "------------------------------------------------------------------------------ " run : Arguments for make "------------------------------------------------------------------------------ function! C_MakeArguments () let s:C_MakeCmdLineArgs= inputdialog("make command line arguments",s:C_MakeCmdLineArgs) endfunction " function! C_Make() exe ":make ".s:C_MakeCmdLineArgs endfunction " " "------------------------------------------------------------------------------ " run : settings "------------------------------------------------------------------------------ function! C_Settings () let settings = "C/C++-Support settings\n\n" let settings = settings."author : ".s:C_AuthorName." (".s:C_AuthorRef.") ".s:C_Email."\n" let settings = settings."company : ".s:C_Company."\n" let settings = settings."project : ".s:C_Project."\n" let settings = settings."copyright holder : ".s:C_CopyrightHolder."\n" if(s:C_CopyrightHolder!="") let settings = settings."copyright year(s) : ".s:C_CopyrightYears."\n" endif let settings = settings."\n" let settings = settings."C / C++ compiler : ".s:C_CCompiler." / ".s:C_CplusCompiler."\n" let settings = settings."C file extension : ".s:C_CExtension." (everything else is C++)\n" let settings = settings."compiler flags : ".s:C_CFlags."\n" let settings = settings."compiler+link flags : ".s:C_LFlags."\n" let settings = settings."libraries : ".s:C_Libs."\n" let settings = settings."pager : ".s:C_Pager."\n" let settings = settings."code snippet directory : ".s:C_CodeSnippets."\n" let settings = settings."\n" let settings = settings."\nMake changes in file c.vim\n" let settings = settings."----------------------------------------------------------------------------------------\n" let settings = settings."C/C++-Support, Version ".s:C_Version." / Dr.-Ing. Fritz Mehner / mehner@fh-swf.de\n" let dummy=confirm( settings, "ok", 1, "Info" ) endfunction " "------------------------------------------------------------------------------ " run : hardcopy "------------------------------------------------------------------------------ function! C_Hardcopy (arg1) let Sou = expand("%") " name of the file in the current buffer " ----- normal mode ---------------- if a:arg1=="n" exe "hardcopy > ".Sou.".ps" endif " ----- visual mode ---------------- if a:arg1=="v" exe "*hardcopy > ".Sou.".part.ps" endif endfunction " "------------------------------------------------------------------------------ " c : C_CreateUnLoadMenuEntries " Create the load/unload entry in the GVIM tool menu, depending on " which script is already loaded. " Author: M.Faulstich "------------------------------------------------------------------------------ " let s:C_Active = -1 " state variable controlling the C-menus " function! C_CreateUnLoadMenuEntries () " " C is now active and was former inactive -> " Insert Tools.Unload and remove Tools.Load Menu " protect the following submenu names against interpolation by using single qoutes (Mn) " if s:C_Active == 1 :aunmenu &Tools.Load\ C\ Support exe 'amenu &Tools.Unload\ C\ Support :call C_Handle()' else " C is now inactive and was former active or in initial state -1 if s:C_Active == 0 " Remove Tools.Unload if C was former inactive :aunmenu &Tools.Unload\ C\ Support else " Set initial state C_Active=-1 to inactive state C_Active=0 " This protects from removing Tools.Unload during initialization after " loading this script let s:C_Active = 0 " Insert Tools.Load endif exe 'amenu &Tools.Load\ C\ Support :call C_Handle()' endif " endfunction " "------------------------------------------------------------------------------ " C : C_Handle " Loads or unloads C support menus. " Author: M.Faulstich "------------------------------------------------------------------------------ function! C_Handle () if s:C_Active == 0 :call C_InitC() let s:C_Active = 1 else aunmenu Comments aunmenu C-Statements aunmenu C-Idioms aunmenu C++ aunmenu C-Run let s:C_Active = 0 endif call C_CreateUnLoadMenuEntries () endfunction " "------------------------------------------------------------------------------ " call C_CreateUnLoadMenuEntries() " create the menu entry in the GVIM tool menu if s:C_ShowMenues == "yes" call C_Handle() " load the menus endif "=====================================================================================