From 9217cc1a0dc9b2a3d9b685a7961f4b776e6d20ec Mon Sep 17 00:00:00 2001 From: nirenjan Date: Tue, 28 Aug 2012 15:58:36 -0700 Subject: [PATCH] Add commonly used Vim scripts --- README.md | 5 ++++- plugin/function-header.vim | 41 ++++++++++++++++++++++++++++++++++ plugin/long-lines.vim | 24 ++++++++++++++++++++ plugin/match-brackets.vim | 43 ++++++++++++++++++++++++++++++++++++ plugin/multiline-comment.vim | 35 +++++++++++++++++++++++++++++ 5 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 plugin/function-header.vim create mode 100644 plugin/long-lines.vim create mode 100644 plugin/match-brackets.vim create mode 100644 plugin/multiline-comment.vim diff --git a/README.md b/README.md index 86415b3..7d31348 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ vim-scripts =========== -Commonly used Vim scripts \ No newline at end of file +Commonly used Vim scripts + +Copy the scripts to your ~/.vim/ folder + diff --git a/plugin/function-header.vim b/plugin/function-header.vim new file mode 100644 index 0000000..5f76480 --- /dev/null +++ b/plugin/function-header.vim @@ -0,0 +1,41 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Function header plugin for vim +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +" This plugin inserts a C/C++ function header as specified below: +" /* +" * Function: +" * Description: +" * Input Args: +" * Output: +" */ +" +" USAGE: +" -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a +" 'plugin' directory in some other directory that is in your +" 'runtimepath'. +" +" -- vim 5: Stick this file somewhere and 'source cscope.vim' it from +" your ~/.vimrc file (or cut and paste it into your .vimrc). +" +" NOTE: +" On pressing in insert mode, this plugin will insert a function-block +" comment and place the cursor on the line to type the function name. +" +" Nirenjan Krishnan nirenjan@gmail.com 2008/12/16 +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Insert function header +function FunctionHeading() + let s:line=line(".") + call setline(s:line ,"/*") + call append(s:line ," * Function: ") + call append(s:line+1," * Description: ") + call append(s:line+2," * Input Args: ") + call append(s:line+3," * Outputs: ") + call append(s:line+4," */") + unlet s:line +endfunction + +imap mz:execute FunctionHeading() `zjA + diff --git a/plugin/long-lines.vim b/plugin/long-lines.vim new file mode 100644 index 0000000..edb8459 --- /dev/null +++ b/plugin/long-lines.vim @@ -0,0 +1,24 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Long line indicator for vim +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +" This plugin marks the characters which exceed the 80 character line +" limitation +" +" USAGE: +" -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a +" 'plugin' directory in some other directory that is in your +" 'runtimepath'. +" +" -- vim 5: Stick this file somewhere and 'source cscope.vim' it from +" your ~/.vimrc file (or cut and paste it into your .vimrc). +" +" NOTE: +" This file will highlight all characters from column 81 onwards +" +" Nirenjan Krishnan nirenjan@gmail.com 2008/12/16 +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +match LineTooLong '\%>80v.\+' +highlight LineTooLong cterm=bold ctermbg=red guibg=LightYellow + diff --git a/plugin/match-brackets.vim b/plugin/match-brackets.vim new file mode 100644 index 0000000..32f4e5a --- /dev/null +++ b/plugin/match-brackets.vim @@ -0,0 +1,43 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Brackets plugin for vim +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +" This plugin inserts corresponding closing braces when the user enters an +" opening brace in insert mode. +" +" USAGE: +" -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a +" 'plugin' directory in some other directory that is in your +" 'runtimepath'. +" +" -- vim 5: Stick this file somewhere and 'source cscope.vim' it from +" your ~/.vimrc file (or cut and paste it into your .vimrc). +" +" NOTE: +" On pressing { in insert mode, this plugin will insert a corresponding closing +" } and will also move the cursor up and indent one level. +" On pressing ( or [, this plugin will insert the corresponding closing ) or ] +" and will place the cursor on the closing ) or ] in insert mode. +" +" Nirenjan Krishnan nirenjan@gmail.com 2008/12/16 +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Braces {} +" Typing { in insert mode will automatically render as +" { +" +" } +imap { {}O + +" Parantheses () +" Typing ( in insert mode will automatically insert a closing +" paranthesis as well and place the cursor on the closing paranthesis +" in insert mode. +imap ( ()i + +" Brackets [] +" Typing [ in insert mode will automatically insert a closing +" bracket as well and place the cursor on the closing bracket +" in insert mode. +imap [ []i + diff --git a/plugin/multiline-comment.vim b/plugin/multiline-comment.vim new file mode 100644 index 0000000..968ff1a --- /dev/null +++ b/plugin/multiline-comment.vim @@ -0,0 +1,35 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Multiline comment plugin for vim +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +" This plugin inserts a multiline comment as specified below: +" /* +" * +" */ +" +" USAGE: +" -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a +" 'plugin' directory in some other directory that is in your +" 'runtimepath'. +" +" -- vim 5: Stick this file somewhere and 'source cscope.vim' it from +" your ~/.vimrc file (or cut and paste it into your .vimrc). +" +" NOTE: +" On pressing in insert mode, this plugin will insert a multiline +" comment and place the cursor on the line to type the comment. +" +" Nirenjan Krishnan nirenjan@gmail.com 2010/09/15 +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Insert multiline comment +function MultiLineComment() + let s:line=line(".") + call setline(s:line ,"/*") + call append(s:line ," * ") + call append(s:line+1," */") + unlet s:line +endfunction + +imap mz:execute MultiLineComment() `zjA +