-syntax on
+" ************************************************************************
+" G E N E R A L S T U F F
+"
-filetype on
-filetype plugin on
+syntax on
set smartindent "Turn on smart indent
set tabstop=4 "set tab character to 4 characters
set expandtab "turn tabs into whitespace
set shiftwidth=4 "indent width for autoindent
-filetype indent on "indent depends on filetype
-
-"let g:solarized_termtrans=1
-let g:solarized_contrast="high"
-set background=dark
-colorscheme solarized
+" Add line numbering
set number
"set numberwidth=4
-"set cursorline "Highlight current line
+" Highlight current line
+"set cursorline
set formatoptions=tcqn2
set modeline
+" Avoids to add 2 spaces after dots when joining lines
set nojoinspaces
" stop indenting when pasting
nnoremap <f7> :set invpaste paste?<CR>
set pastetoggle=<f7>
-" then try hitting the F7 key while in insert mode
-" or just :set paste
set showmode
" Disable auto-identing
:set columns=160
endif
+
+" ************************************************************************
+" C O L O R T H E M E O P T I O N S
+"
+
+" solarized optons
+"let g:solarized_termtrans=1
+let g:solarized_contrast="high"
+set background=dark
+
+" sets theme
+colorscheme solarized
+
+" Toggles background (dark vs. light theme)
if !exists("no_plugin_maps") && !hasmapto('<Plug>ToggleBackground')
call togglebg#map("<F5>")
endif
+
+
+" ************************************************************************
+" B E G I N A U T O C O M M A N D S
+"
+
+if has("autocmd")
+
+ " Enable file type detection.
+ " Use the default filetype settings, so that mail gets 'tw' set to 72,
+ " 'cindent' is on in C files, etc.
+ " Also load indent files, to automatically do language-dependent indenting.
+ filetype plugin indent on
+
+ " Add an autocommand to update serial in bind zone files
+ command Soa :%s/\(2[0-9]\{7}\)\([0-9]\{2}\)\(\s*;\s*serial\)/\=UpdateDNSSerialZone(submatch(1), submatch(2)) . submatch(3)/gc
+ autocmd BufWritePre /etc/bind/db.* Soa
+
+endif
+
+
+" ************************************************************************
+" F U N C T I O N S
+"
+
+" This function is used to update the serial in the SOA from a bind file
+function! UpdateDNSSerialZone(date, num)
+ if (strftime("%Y%m%d") == a:date)
+ return a:date . a:num+1
+ endif
+ return strftime("%Y%m%d") . '01'
+endfunction