diff --git a/bin/sync-vim.sh b/bin/sync-vim.sh index 36dc210..7bfda7a 100644 --- a/bin/sync-vim.sh +++ b/bin/sync-vim.sh @@ -6,4 +6,5 @@ if [ ! -d "~/.vim" ]; then echo "Syncing user dictionary" && cp ~/.vim/spell/* ~/.dotfiles/vim/spell/ echo "Syncing user colors" && cp ~/.vim/colors/* ~/.dotfiles/vim/colors/ echo "Syncing after directory" && cp -r ~/.vim/after ~/.dotfiles/vim/ + echo "Syncing templates" && cp -r ~/.vim/templates ~/.dotfiles/vim/ fi diff --git a/vim/templates/c_header_notice b/vim/templates/c_header_notice new file mode 100644 index 0000000..bbe9087 --- /dev/null +++ b/vim/templates/c_header_notice @@ -0,0 +1,6 @@ +/*======================================================================================= + File: + Creation Date: + Creator: Michael Campagnaro + Notice: (C) Copyright $year by Jelly Pixel, Inc. All Rights Reserved. + =======================================================================================*/ diff --git a/vim/templates/skeleton.sh b/vim/templates/skeleton.sh new file mode 100644 index 0000000..3b96a03 --- /dev/null +++ b/vim/templates/skeleton.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if which tput >/dev/null 2>&1; then + ncolors=$(tput colors) +fi +if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then + RED="$(tput setaf 1)" + GREEN="$(tput setaf 2)" + YELLOW="$(tput setaf 3)" + BLUE="$(tput setaf 4)" + BOLD="$(tput bold)" + NORMAL="$(tput sgr0)" +else + RED="" + GREEN="" + YELLOW="" + BLUE="" + BOLD="" + NORMAL="" +fi + +set -e + +cwd=$PWD +platform=`uname` # 'Linux', 'Darwin', etc + +printf "${YELLOW}Platform: $platform${NORMAL}\n" diff --git a/vimrc b/vimrc index f6b3868..5623b6a 100644 --- a/vimrc +++ b/vimrc @@ -286,7 +286,7 @@ imap """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " CUSTOM AUTOCMDS """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -augroup vimrcEx +augroup campoCmds " Clear all autocmds in the group autocmd! autocmd FileType text setlocal textwidth=78 @@ -300,8 +300,30 @@ augroup vimrcEx " Indent p tags autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif -augroup END + "//////////////////////////////////////////////////////////////// + " FILE TEMPLATES + "//////////////////////////////////////////////////////////////// + + " Shell script template + autocmd BufNewFile *.sh 0r ~/.vim/templates/skeleton.sh + + " C/C++ template + autocmd bufnewfile *.{c,cc,cpp,h,hpp} 0r ~/.vim/templates/c_header_notice + autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/File:.*/s//File: " .expand("%") + autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/Creation Date:.*/s//Creation Date: " .strftime("%Y-%m-%d") + autocmd bufnewfile *.{c,cc,cpp,h,hpp} exe "2," . 6 . "g/$year/s//" .strftime("%Y") + function! s:InsertHeaderGates() + let gatename = substitute(toupper(expand("%:t")), "\\.", "_", "g") + execute "normal! ggO#ifndef " . gatename + normal! Go + normal! Go + execute "normal! Go#define " . gatename . " " + execute "normal! o#endif" + normal! kkk + endfunction + autocmd bufnewfile *.{h,hpp} call InsertHeaderGates() +augroup END """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " MISC KEY MAPS