diff --git a/vim/snippets/_.snippets b/vim/snippets/_.snippets new file mode 100644 index 0000000..6df2abf --- /dev/null +++ b/vim/snippets/_.snippets @@ -0,0 +1,8 @@ +snippet ### + ################################################################################ + # ${1:filename} - ${2:filedescription} + # + # author: ${3:`g:snips_author`} <${4:`g:snips_email`}> + ################################################################################ + + diff --git a/vim/snippets/c.snippets b/vim/snippets/c.snippets new file mode 100644 index 0000000..e1c4f05 --- /dev/null +++ b/vim/snippets/c.snippets @@ -0,0 +1,113 @@ +# main() +snippet main + int main(int argc, const char *argv[]) + { + ${1} + return 0; + } +snippet mainn + int main(void) + { + ${1} + return 0; + } +# #include <...> +snippet inc + #include <${1:stdio}.h>${2} +# #include "..." +snippet Inc + #include "${1:`Filename("$1.h")`}"${2} +# #ifndef ... #define ... #endif +snippet Def + #ifndef $1 + #define ${1:SYMBOL} ${2:value} + #endif${3} +snippet def + #define +snippet ifdef + #ifdef ${1:FOO} + ${2:#define } + #endif +snippet #if + #if ${1:FOO} + ${2} + #endif +# Header Include-Guard +snippet once + #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`} + + #define $1 + + ${2} + + #endif /* end of include guard: $1 */ +# If Condition +snippet if + if (${1:/* condition */}) { + ${2:/* code */} + } +snippet el + else { + ${1} + } +# Ternary conditional +snippet t + ${1:/* condition */} ? ${2:a} : ${3:b} +# Do While Loop +snippet do + do { + ${2:/* code */} + } while (${1:/* condition */}); +# While Loop +snippet wh + while (${1:/* condition */}) { + ${2:/* code */} + } +# For Loop +snippet for + for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { + ${4:/* code */} + } +# Custom For Loop +snippet forr + for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { + ${5:/* code */} + } +# Function +snippet fun + ${1:void} ${2:function_name}(${3}) + { + ${4:/* code */} + } +# Function Declaration +snippet fund + ${1:void} ${2:function_name}(${3});${4} +# Typedef +snippet td + typedef ${1:int} ${2:MyCustomType};${3} +# Struct +snippet st + struct ${1:`Filename('$1_t', 'name')`} { + ${2:/* data */} + }${3: /* optional variable list */};${4} +# Typedef struct +snippet tds + typedef struct ${2:_$1 }{ + ${3:/* data */} + } ${1:`Filename('$1_t', 'name')`}; +# Typdef enum +snippet tde + typedef enum { + ${1:/* data */} + } ${2:foo}; +# printf +# unfortunately version this isn't as nice as TextMates's, given the lack of a +# dynamic `...` +snippet pr + printf("${1:%s}\n"${2});${3} +# fprintf (again, this isn't as nice as TextMate's version, but it works) +snippet fpr + fprintf(${1:stderr}, "${2:%s}\n"${3});${4} +# This is kind of convenient +snippet . + [${1}]${2} diff --git a/vim/snippets/python.snippets b/vim/snippets/python.snippets new file mode 100644 index 0000000..eefd861 --- /dev/null +++ b/vim/snippets/python.snippets @@ -0,0 +1,3 @@ +snippet #! + #!/usr/bin/env python + diff --git a/vim/vimrc b/vim/vimrc index c5af56b..3616bb7 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -4,95 +4,59 @@ " author: mutantmonkey " ############################################################################## -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" General settings -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" General Settings {{{ -" Disable backup files -set nobackup +set hidden " Switch buffers without saving +set nobackup " Disable backup files +set nocompatible " Disable vi-compatible mode +set noerrorbells " Don't make noise on errors +set shortmess+=I " Do not show welcome screen +set title " Update window title -" Disable vi-compatible mode -set nocompatible +" }}} -" Don't make noise -set noerrorbells -" Switch buffers without saving -set hidden +" Color Settings {{{ -" Update window title -set title - -" Hide Vim welcome screen -set shortmess+=I - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" UI Settings -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -" Color scheme -colors xoria256 - -" Highlight current line -set cursorline +if $TERM =~ "256color" || has('gui_running') + colorscheme xoria256 +else + colorscheme darkdot +endif -" Show line numbers -set number +" }}} -" Highlight matching brackets -set showmatch -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" GUI Settings -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" GUI Settings {{{ if has("gui_running") - " Color scheme - "colors asmanian_blood - "colors darkspectrum - - " Disable tear-off menus - set guioptions-=t + set guioptions-=t " Disable tear-off menus " Window size set columns=100 set lines=40 endif -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Editing -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" }}} -" Make backspace more flexible -set backspace=indent,eol,start -" Allow use of arrow keys while in insert mode -set esckeys +" Editing {{{ -" Don't stay in insert mode -set noinsertmode +set backspace=indent,eol,start " Make backspace key behave normally +set esckeys " Allow use of arrow keys while in insert mode +set noinsertmode " Don't stay in insert mode +set spell " Enable spell checking -" Prevent cursor from moving to left one space when exiting insert mode -"inoremap +set cursorline " Highlight current line +set number " Show line numbers -" Show matching parentheses -set showmatch +set showmatch " Highlight matching pairs +set matchpairs+=<:> " Make < and > match -" Spell checking -set spell +" }}} -" Syntax highlighting -syntax enable -" Highlight HTML code inside of PHP -let php_htmlInStrings=1 - -" Highlight MySQL queries inside of PHP -let php_sql_query=1 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Indentation -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Indentation {{{ " Automatic indentation on new lines set autoindent @@ -111,9 +75,25 @@ set tabstop=4 set shiftwidth=4 set softtabstop=4 -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" File formats -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" }}} + + +" Folding {{{ + +if has('folding') + set foldenable " Enable folding + set foldmethod=marker " Fold on marker + set foldopen-=search " Do not open folds when searching + set foldopen-=undo " Do not open folds when using undo + "set foldlevel=999 " Show folds at start + set foldmarker={{{,}}} " Use default fold marker + set foldcolumn=0 " Do not use a fold column +endif + +" }}} + + +" File Formats {{{ " Unicode support set encoding=utf-8 @@ -121,15 +101,19 @@ set encoding=utf-8 " Support UNIX, DOS, and Mac line endings set fileformats=unix,dos,mac +" Enable filetype auto-detection +filetype plugin on + " Enable filetype-specific indentation filetype plugin indent on " Enable Sparkup plugin for HTML files autocmd FileType html source ~/.config/vim/scripts/sparkup.vim -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Searching -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" }}} + + +" Searching {{{ " Highlight set hlsearch @@ -138,3 +122,30 @@ set hlsearch set ignorecase set smartcase +" }}} + + +" Syntax Highlighting {{{ + +" Syntax highlighting +syntax enable + +" Highlight HTML code inside of PHP +let php_htmlInStrings=1 + +" Highlight MySQL queries inside of PHP +let php_sql_query=1 + +" }}} + + +" Plugins {{{ + +" SnipMate +set runtimepath+=~/.config/vim/plugin/snipmate/after/ +let g:snips_author ='mutantmonkey' +let g:snips_email = 'mutantmonkey@gmail.com' +let g:snippets_dir = '/home/mutantmonkey/.config/vim/snippets' + +" }}} + diff --git a/vimrc b/vimrc index 8ab5379..7e795dc 100644 --- a/vimrc +++ b/vimrc @@ -4,6 +4,6 @@ " author: mutantmonkey " ############################################################################## -set runtimepath=~/.config/vim/,/usr/share/vim/vimfiles,$VIMRUNTIME +set runtimepath=~/.config/vim/,/usr/share/vim/vimfiles/,$VIMRUNTIME source ~/.config/vim/vimrc