" call pathogen#infect() " autowrite every few minutes " set aw set shiftwidth=4 colo ron " use Ctrl+L to toggle the line number counting method function! g:ToggleNuMode() if(&rnu == 1) set nu else set rnu endif endfunc nnoremap :call g:ToggleNuMode() " Make vim more useful set nocompatible " Enhance command-line completion set wildmenu " Allow cursor keys in insert mode set esckeys " Optimize for fast terminal connections set ttyfast " Add the g flag to search/replace by default set gdefault " Use UTF-8 without BOM set encoding=utf-8 nobomb " Change mapleader let mapleader="," " Don’t add empty newlines at the end of files set binary set noeol " Centralize backups, swapfiles and undo history set backupdir=~/.vim/backups set directory=~/.vim/swaps if exists("&undodir") set undodir=~/.vim/undo endif " Enable line numbers set number " Enable syntax highlighting syntax on " Highlight current line set cursorline " Make tabs as wide as four spaces set tabstop=4 " Show “invisible” characters set lcs=tab:▸\ ,trail:·,eol:¬,nbsp:_ " set lcs=tab:▸\ ,·,eol:¬,nbsp:_ set list " Highlight searches set hlsearch " Ignore case of searches set ignorecase " Highlight dynamically as pattern is typed set incsearch " Always show status line set laststatus=2 " Enable mouse in all modes - I do not want " set mouse=a " Disable error bells set noerrorbells " Don’t reset cursor to start of line when moving around. set nostartofline " Show the cursor position set ruler " Don’t show the intro message when starting vim set shortmess=atI " Show the current mode set showmode " Show the filename in the window titlebar set title " Show the (partial) command as it’s being typed set showcmd " number of columns of TAB set to 4 set softtabstop=4 " Use relative line numbers if exists("&relativenumber") set relativenumber au BufReadPost * set relativenumber endif " Start scrolling three lines before the horizontal window border set scrolloff=3 " Strip trailing whitespace (,ss) function! StripWhitespace() let save_cursor = getpos(".") let old_query = getreg('/') :%s/\s\+$//e call setpos('.', save_cursor) call setreg('/', old_query) endfunction noremap ss :call StripWhitespace() " Save a file as root (,W) noremap W :w !sudo tee % > /dev/null " Automatic commands if has("autocmd") " Enable file type detection filetype on " Treat .json files as .js autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript endif " REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.¬ filetype plugin on " IMPORTANT: grep will sometimes skip displaying the file name if you¬ " search in a singe file. This will confuse Latex-Suite. Set your grep¬ " program to always generate a file-name. set grepprg=grep\ -nH\ $* " OPTIONAL: This enables automatic indentation as you type. filetype indent on set expandtab " OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to " 'plaintex' instead of 'tex', which results in vim-latex not being loaded. " The following changes the default filetype back to 'tex': let g:tex_flavor='latex' " :set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:< " Transparent editing of gpg encrypted files. " By Wouter Hanegraaff augroup encrypted au! " First make sure nothing is written to ~/.viminfo while editing " an encrypted file. autocmd BufReadPre,FileReadPre *.gpg set viminfo= " We don't want a various options which write unencrypted data to disk autocmd BufReadPre,FileReadPre *.gpg set noswapfile noundofile nobackup " Switch to binary mode to read the encrypted file autocmd BufReadPre,FileReadPre *.gpg set bin autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2 autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null " Switch to normal mode for editing autocmd BufReadPost,FileReadPost *.gpg set nobin autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r") " Convert all text to encrypted text before writing autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-recipient-self -ae 2>/dev/null " Undo the encryption so we are back in the normal text, directly " after the file has been written. autocmd BufWritePost,FileWritePost *.gpg u augroup END