Add some vim templates
This commit is contained in:
parent
b1d21192f8
commit
caf03e391a
|
@ -6,4 +6,5 @@ if [ ! -d "~/.vim" ]; then
|
||||||
echo "Syncing user dictionary" && cp ~/.vim/spell/* ~/.dotfiles/vim/spell/
|
echo "Syncing user dictionary" && cp ~/.vim/spell/* ~/.dotfiles/vim/spell/
|
||||||
echo "Syncing user colors" && cp ~/.vim/colors/* ~/.dotfiles/vim/colors/
|
echo "Syncing user colors" && cp ~/.vim/colors/* ~/.dotfiles/vim/colors/
|
||||||
echo "Syncing after directory" && cp -r ~/.vim/after ~/.dotfiles/vim/
|
echo "Syncing after directory" && cp -r ~/.vim/after ~/.dotfiles/vim/
|
||||||
|
echo "Syncing templates" && cp -r ~/.vim/templates ~/.dotfiles/vim/
|
||||||
fi
|
fi
|
||||||
|
|
6
vim/templates/c_header_notice
Normal file
6
vim/templates/c_header_notice
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/*=======================================================================================
|
||||||
|
File:
|
||||||
|
Creation Date:
|
||||||
|
Creator: Michael Campagnaro
|
||||||
|
Notice: (C) Copyright $year by Jelly Pixel, Inc. All Rights Reserved.
|
||||||
|
=======================================================================================*/
|
27
vim/templates/skeleton.sh
Normal file
27
vim/templates/skeleton.sh
Normal file
|
@ -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"
|
26
vimrc
26
vimrc
|
@ -286,7 +286,7 @@ imap <right> <nop>
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" CUSTOM AUTOCMDS
|
" CUSTOM AUTOCMDS
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
augroup vimrcEx
|
augroup campoCmds
|
||||||
" Clear all autocmds in the group
|
" Clear all autocmds in the group
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType text setlocal textwidth=78
|
autocmd FileType text setlocal textwidth=78
|
||||||
|
@ -300,8 +300,30 @@ augroup vimrcEx
|
||||||
|
|
||||||
" Indent p tags
|
" Indent p tags
|
||||||
autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
|
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 <SID>InsertHeaderGates()
|
||||||
|
augroup END
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" MISC KEY MAPS
|
" MISC KEY MAPS
|
||||||
|
|
Loading…
Reference in New Issue
Block a user