syntax on " 4 space tab set tabstop=4 " use 4 space tab for > and < set shiftwidth=4 " use shiftwidth for beginning of the line set smarttab " use spaces when tab is pressed set expandtab " treat spaces as tabstop, so can delete easily set softtabstop=4 " start properly tabbed in when pressing enter set autoindent " Tell vim to remember certain things when we exit " '10 : marks will be remembered for up to 10 previously edited files " "100 : will save up to 100 lines for each register " :20 : up to 20 lines of command-line history will be remembered " % : saves and restores the buffer list " n... : where to save the viminfo files set viminfo='10,\"100,:20,%,n~/.viminfo " restore cursor to previous position function! ResCur() if line("'\"") <= line("$") normal! g`" return 1 endif endfunction " part of restore cursor to previous position augroup resCur autocmd! autocmd BufWinEnter * call ResCur() augroup END " make backspace work properly set backspace=indent,eol,start " highlight search items set hlsearch " use to toggle listchars (display whitespace and other invisible chars set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:< noremap :set list! inoremap :set list! cnoremap :set list! " Attempt to detect iptables rule files and set syntax if getline(1) =~ "^# Generated by iptables-save" || \ getline(1) =~ "^# Firewall configuration written by" setfiletype iptables set filetype=iptables set commentstring=#%s finish endif " Assume .v4 and .v6 are iptables rules files as a fallback autocmd BufNewFile,BufRead *.v4 set syntax=iptables autocmd BufNewFile,BufRead *.v6 set syntax=iptables