Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Björn-Egil Dahlberg
committed
Sep 22, 2012
0 parents
commit 41aec78
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Header Comments in Vim | ||
---------------------- | ||
|
||
A simple vim-plugin to generate header comments | ||
for Author, Copyright and Creation Date. | ||
|
||
Example: | ||
|
||
%% | ||
%% Copyright (C) 2012 Hapida AB | ||
%% | ||
%% File: test.erl | ||
%% Author: Björn-Egil Dahlberg | ||
%% Created: 2012-09-22 | ||
%% | ||
|
||
|
||
Author and Copyright holder is set in your .vimrc | ||
|
||
Example: | ||
|
||
" Define headers for copyright and author | ||
let g:header_comment_author = "Björn-Egil Dahlberg" | ||
let g:header_comment_copyright = "Hapida AB" | ||
|
||
Note: | ||
This plugin was mainly created to get an idea on how vim plugins works =) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
" | ||
" Copyright (C) 2012 Hapida AB | ||
" | ||
" File: header-comment.vim | ||
" Author: Björn-Egil Dahlberg | ||
" Created: 2012-09-22 | ||
" | ||
|
||
autocmd bufnewfile *.erl call MakeFileHeader('%%','%%','%%') | ||
autocmd bufnewfile *.hrl call MakeFileHeader('%%','%%','%%') | ||
autocmd bufnewfile *.vim call MakeFileHeader('" ','" ','" ') | ||
autocmd bufnewfile *.c call MakeFileHeader('/* ',' *',' */') | ||
|
||
" Header | ||
" fc = firstcomment, ex. /* | ||
" mc = middle comments ex. * | ||
" lc = last comment ex. */ | ||
function! MakeFileHeader(fc,mc,lc) | ||
set paste | ||
let s:author = "" | ||
let s:copyright = "" | ||
if exists('g:header_comment_author') | ||
let s:author = g:header_comment_author | ||
else | ||
echo "g:header_comment_author is not defined in .vimrc" | ||
end | ||
if exists('g:header_comment_copyright') | ||
let s:copyright = g:header_comment_copyright | ||
else | ||
echo "g:header_comment_copyright is not defined in .vimrc" | ||
end | ||
|
||
let s:comment = a:fc . "\r" | ||
let s:comment .= a:mc . " Copyright (C) " . strftime("%Y") . " " . s:copyright . "\r" | ||
let s:comment .= a:mc . "\r" | ||
let s:comment .= a:mc . " File: " . expand('%:t') . "\r" | ||
let s:comment .= a:mc . " Author: " . s:author . "\r" | ||
let s:comment .= a:mc . " Created: " . strftime("%Y-%m-%d") . "\r" | ||
let s:comment .= a:lc . "\r" | ||
exec "normal i" . s:comment | ||
set nopaste | ||
endfunction |