From 1c019761dfaf6be82de9284fa5e2b9dbfbdec27d Mon Sep 17 00:00:00 2001 From: Ryan Kavanagh Date: Sun, 14 Aug 2011 17:16:55 -0400 Subject: Initial import --- .vim/ftplugin/c.vim | 294 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 294 insertions(+) create mode 100644 .vim/ftplugin/c.vim (limited to '.vim/ftplugin/c.vim') diff --git a/.vim/ftplugin/c.vim b/.vim/ftplugin/c.vim new file mode 100644 index 0000000..ff5a637 --- /dev/null +++ b/.vim/ftplugin/c.vim @@ -0,0 +1,294 @@ +" Vim filetype plugin file +" +" Language : C / C++ +" Plugin : c.vim (version 5.0) +" Maintainer : Fritz Mehner +" Revision : $Id: c.vim,v 1.18 2007/11/20 18:12:02 mehner Exp $ +" +" This will enable keyword completion for C and C++ +" using Vim's dictionary feature |i_CTRL-X_CTRL-K|. +" ----------------------------------------------------------------- +" +" Only do this when not done yet for this buffer +" +if exists("b:did_C_ftplugin") + finish +endif +let b:did_C_ftplugin = 1 +" +" ---------- C/C++ dictionary ----------------------------------- +" +if exists("g:C_Dictionary_File") + silent! exec 'setlocal dictionary+='.g:C_Dictionary_File +endif +" +" ---------- F-key mappings ------------------------------------ +" +" Alt-F9 write buffer and compile +" F9 compile and link +" Ctrl-F9 run executable +" Shift-F9 command line arguments +" + map :call C_Compile():redraw:call C_HlMessage() +imap :call C_Compile():redraw:call C_HlMessage() +" + map :call C_Link():redraw:call C_HlMessage() +imap :call C_Link():redraw:call C_HlMessage() +" +" seems to be essential here: + map :call C_Run() +imap :call C_Run() +" + map :call C_Arguments() +imap :call C_Arguments() +" +" alternate file plugin +" +"if exists("loaded_alternateFile") +" map :A +"imap :A +"endif +" +" +" ---------- KEY MAPPINGS : MENU ENTRIES ------------------------------------- +" +" ---------- comments menu ------------------------------------------------ +" + + noremap cl :call C_LineEndComment() +inoremap cl :call C_LineEndComment()a +vnoremap cl :call C_MultiLineEndComments() + noremap cj :call C_AdjustLineEndComm("a") +vnoremap cj :call C_AdjustLineEndComm("v") +inoremap cj :call C_AdjustLineEndComm("a")a + noremap cs :call C_GetLineEndCommCol() + noremap c* :call C_CodeComment("a","yes"):nohlsearchj +vnoremap c* :call C_CodeComment("v","yes"):nohlsearchj + noremap c/ :call C_CodeComment("a","no"):nohlsearchj +vnoremap c/ :call C_CodeComment("v","no"):nohlsearchj + noremap co :call C_CommentCode("a"):nohlsearch +vnoremap co :call C_CommentCode("v"):nohlsearch + + noremap cfr :call C_InsertTemplate("comment.frame") + noremap cfu :call C_InsertTemplate("comment.function") + noremap cme :call C_InsertTemplate("comment.method") + noremap ccl :call C_InsertTemplate("comment.class") + +inoremap cfr :call C_InsertTemplate("comment.frame") +inoremap cfu :call C_InsertTemplate("comment.function") +inoremap cme :call C_InsertTemplate("comment.method") +inoremap ccl :call C_InsertTemplate("comment.class") + + noremap cd a=C_InsertDateAndTime('d') +inoremap cd =C_InsertDateAndTime('d') + noremap ct a=C_InsertDateAndTime('dt') +inoremap ct =C_InsertDateAndTime('dt') +" +" ---------- statements menu ------------------------------------------------ +" + noremap sd :call C_InsertTemplate("statements.do-while") +vnoremap sd :call C_InsertTemplate("statements.do-while", "v") +inoremap sd :call C_InsertTemplate("statements.do-while") + + noremap sf :call C_InsertTemplate("statements.for") +inoremap sf :call C_InsertTemplate("statements.for") + + noremap sfo :call C_InsertTemplate("statements.for-block") +vnoremap sfo :call C_InsertTemplate("statements.for-block", "v") +inoremap sfo :call C_InsertTemplate("statements.for-block") + + noremap si :call C_InsertTemplate("statements.if") +inoremap si :call C_InsertTemplate("statements.if") + + noremap sif :call C_InsertTemplate("statements.if-block") +vnoremap sif :call C_InsertTemplate("statements.if-block", "v") +inoremap sif :call C_InsertTemplate("statements.if-block") + + noremap sie :call C_InsertTemplate("statements.if-else") +vnoremap sie :call C_InsertTemplate("statements.if-else", "v") +inoremap sie :call C_InsertTemplate("statements.if-else") + + noremap sife :call C_InsertTemplate("statements.if-block-else") +vnoremap sife :call C_InsertTemplate("statements.if-block-else", "v") +inoremap sife :call C_InsertTemplate("statements.if-block-else") + + noremap sw :call C_InsertTemplate("statements.while") +inoremap sw :call C_InsertTemplate("statements.while") + + noremap swh :call C_InsertTemplate("statements.while-block") +vnoremap swh :call C_InsertTemplate("statements.while-block", "v") +inoremap swh :call C_InsertTemplate("statements.while-block") + + noremap ss :call C_InsertTemplate("statements.switch") +vnoremap ss :call C_InsertTemplate("statements.switch", "v") +inoremap ss :call C_InsertTemplate("statements.switch") + + noremap sc :call C_InsertTemplate("statements.case") +inoremap sc :call C_InsertTemplate("statements.case") + + noremap s{ :call C_InsertTemplate("statements.block") +vnoremap s{ :call C_InsertTemplate("statements.block", "v") +inoremap s{ :call C_InsertTemplate("statements.block") +" +" ---------- preprocessor menu ---------------------------------------------- +" +inoremap p< o#include<> +inoremap p" o#include"" +inoremap pd :call C_InsertTemplate("preprocessor.define") +inoremap pu :call C_InsertTemplate("preprocessor.undefine") +" + noremap p< o#include<> + noremap p" o#include"" + noremap pd :call C_InsertTemplate("preprocessor.define") + noremap pu :call C_InsertTemplate("preprocessor.undefine") + + noremap pie :call C_InsertTemplate("preprocessor.if-else-endif") + noremap pid :call C_InsertTemplate("preprocessor.ifdef-else-endif") + noremap pin :call C_InsertTemplate("preprocessor.ifndef-else-endif") + noremap pind :call C_InsertTemplate("preprocessor.ifndef-def-endif") + noremap pi0 :call C_PPIf0("a")2ji + +vnoremap pie :call C_InsertTemplate("preprocessor.if-else-endif", "v") +vnoremap pid :call C_InsertTemplate("preprocessor.ifdef-else-endif", "v") +vnoremap pin :call C_InsertTemplate("preprocessor.ifndef-else-endif", "v") +vnoremap pind :call C_InsertTemplate("preprocessor.ifndef-def-endif", "v") +vnoremap pi0 :call C_PPIf0("v") + +inoremap pie :call C_InsertTemplate("preprocessor.if-else-endif") +inoremap pid :call C_InsertTemplate("preprocessor.ifdef-else-endif") +inoremap pin :call C_InsertTemplate("preprocessor.ifndef-else-endif") +inoremap pind :call C_InsertTemplate("preprocessor.ifndef-def-endif") +inoremap pi0 :call C_PPIf0("a")2ji + + noremap pr0 :call C_PPIf0Remove() +" +" ---------- idioms menu ---------------------------------------------------- +" + noremap if :call C_InsertTemplate("idioms.function") +vnoremap if :call C_InsertTemplate("idioms.function", "v") +inoremap if :call C_InsertTemplate("idioms.function") + noremap isf :call C_InsertTemplate("idioms.function-static") +vnoremap isf :call C_InsertTemplate("idioms.function-static", "v") +inoremap isf :call C_InsertTemplate("idioms.function-static") + noremap im :call C_InsertTemplate("idioms.main") +vnoremap im :call C_InsertTemplate("idioms.main", "v") +inoremap im :call C_InsertTemplate("idioms.main") +" + noremap i0 :call C_CodeFor("up" , "a")a +vnoremap i0 :call C_CodeFor("up" , "v") +inoremap i0 :call C_CodeFor("up" , "a")a + noremap in :call C_CodeFor("down", "a")a +vnoremap in :call C_CodeFor("down", "v") +inoremap in :call C_CodeFor("down", "a")a +" + noremap ie :call C_InsertTemplate("idioms.enum") +vnoremap ie :call C_InsertTemplate("idioms.enum" , "v") +inoremap ie :call C_InsertTemplate("idioms.enum") + noremap is :call C_InsertTemplate("idioms.struct") +vnoremap is :call C_InsertTemplate("idioms.struct", "v") +inoremap is :call C_InsertTemplate("idioms.struct") + noremap iu :call C_InsertTemplate("idioms.union") +vnoremap iu :call C_InsertTemplate("idioms.union" , "v") +inoremap iu :call C_InsertTemplate("idioms.union") +" + noremap ip oprintf("\n");2F"a +inoremap ip printf("\n");2F"a + noremap isc oscanf("", & );F"i +inoremap isc scanf("", & );F"i +" + noremap ica :call C_InsertTemplate("idioms.calloc") +inoremap ica :call C_InsertTemplate("idioms.calloc") + noremap ima :call C_InsertTemplate("idioms.malloc") +inoremap ima :call C_InsertTemplate("idioms.malloc") +" + noremap isi isizeof() +vnoremap isi ssizeof()P +inoremap isi sizeof() + noremap ias oassert(); +vnoremap ias sassert();F(p +inoremap ias assert(); +" + noremap ii :call C_InsertTemplate("idioms.open-input-file") +inoremap ii :call C_InsertTemplate("idioms.open-input-file") + noremap io :call C_InsertTemplate("idioms.open-output-file") +inoremap io :call C_InsertTemplate("idioms.open-output-file") +" +" ---------- snippet menu ---------------------------------------------------- +" + noremap nr :call C_CodeSnippet("r") + noremap nw :call C_CodeSnippet("w") +vnoremap nw :call C_CodeSnippet("wv") + noremap ne :call C_CodeSnippet("e") +" + noremap np :call C_ProtoPick("n") +vnoremap np :call C_ProtoPick("v") + noremap ni :call C_ProtoInsert() + noremap nc :call C_ProtoClear() + noremap ns :call C_ProtoShow() +" +" ---------- C++ menu ---------------------------------------------------- +" + noremap +m :call C_InsertTemplate("cpp.method-implementation") +inoremap +m :call C_InsertTemplate("cpp.method-implementation") + noremap +c :call C_InsertTemplate("cpp.class") +inoremap +c :call C_InsertTemplate("cpp.class") + noremap +cn :call C_InsertTemplate("cpp.class-using-new") +inoremap +cn :call C_InsertTemplate("cpp.class-using-new") + + noremap +tm :call C_InsertTemplate("cpp.template-method-implementation") +inoremap +tm :call C_InsertTemplate("cpp.template-method-implementation") + noremap +tc :call C_InsertTemplate("cpp.template-class") +inoremap +tc :call C_InsertTemplate("cpp.template-class") + noremap +tcn :call C_InsertTemplate("cpp.template-class-using-new") +inoremap +tcn :call C_InsertTemplate("cpp.template-class-using-new") + + noremap +tf :call C_InsertTemplate("cpp.template-function") +inoremap +tf :call C_InsertTemplate("cpp.template-function") + + noremap +ec :call C_InsertTemplate("cpp.error-class") +inoremap +ec :call C_InsertTemplate("cpp.error-class") + + noremap +tr :call C_InsertTemplate("cpp.try-catch") +vnoremap +tr :call C_InsertTemplate("cpp.try-catch", "v") +inoremap +tr :call C_InsertTemplate("cpp.try-catch") + + noremap +ca :call C_InsertTemplate("cpp.catch") +vnoremap +ca :call C_InsertTemplate("cpp.catch", "v") +inoremap +ca :call C_InsertTemplate("cpp.catch") + + noremap +c. :call C_InsertTemplate("cpp.catch-points") +vnoremap +c. :call C_InsertTemplate("cpp.catch-points", "v") +inoremap +c. :call C_InsertTemplate("cpp.catch-points") +" +" +" ---------- run menu -------------------------------------------------------- +" + map rc :call C_Compile():redraw:call C_HlMessage() + map rl :call C_Link():redraw:call C_HlMessage() + map rr :call C_Run() + map ra :call C_Arguments() + map rm :call C_Make() + map rg :call C_MakeArguments() + map rp :call C_SplintCheck():redraw:call C_HlMessage() + map ri :call C_SplintArguments() + map rd :call C_Indent("a"):redraw:call C_HlMessage() +vmap rd :call C_Indent("v"):redraw:call C_HlMessage() + map rh :call C_Hardcopy("n") +vmap rh :call C_Hardcopy("v") + map rs :call C_Settings() + map rt :call C_RebuildTemplates() + if has("unix") + map rx :call C_XtermSize() + endif + map ro :call C_Toggle_Gvim_Xterm() +" +" Abraxas CodeCheck (R) +" +if executable("check") + map rk :call C_CodeCheck():redraw:call C_HlMessage() + map re :call C_CodeCheckArguments() +endif +" ---------- plugin help ----------------------------------------------------- +" + map h :call C_HelpCsupport() +" -- cgit v1.2.3