nmap x nmap X map gqap map! gqapi map :w map! :wi map ZZ map! ZZ map :q! map! :q! source ~/.vim.ispell map :let @_=SpellCheck() map! :let @_=SpellCheck()i " No, it is not VI, it is VIM! Set this first, it is important. set nocompatible " Generic/interface settings "set nobackup " Do not make a backup before overwriting a file set showbreak=+\ " Precede continued screen lines set comments=b:#,:%,fb:-,n:>,n:)b:\"n:: " Comments may start with these chars: #%>": set noendofline " No will be written for the last line in the file set equalprg=fmt " External program to use for "=" command set formatoptions=tcrq " How to do automatic formatting set keywordprg=man\ -k " Display man entries for `K' lookup "set lazyredraw " Do not update screen while executing macros set list listchars=tab:>_,trail:_,extends:+ " ,eol:$ " Show tabs, trailing spaces, long lines set matchpairs=(:),{:},[:],<:> " Matching pair characters set shortmess=ato " Overwrite message for writing a file with subsequent message set showmatch " When a bracket is inserted, briefly jump to the matching one set sidescroll=1 " The minimal number of columns to scroll horizontally set nostartofline " Keep curosr's column set suffixes= " Set a priority between files with almost the same name set timeout timeoutlen=3000 " Set timeout on mappings/keycodes to 3 seconds set viminfo='10 " Maximum number of previously edited files for which the marks are remembered set whichwrap=b,s,h,l,<,>,[,] " Wrap to the previous/next line on all keys set wildmenu " Command-line completion operates in an enhanced mode set wildmode=longest,list,list:full " Bash-vim wildcard behavior set nowrap " Do not visually wrap long lines - do not make it look like there are line breaks where there aren't set esckeys " show escape set hidden set novisualbell " I hate visual bell. set noerrorbells " I prefer a silent workspace. set fo=cqrt set ls=2 set textwidth=72 " Windows/buffers settings set hidden " Allow to switch between buffers/windows when the buffer was modified set laststatus=2 " Always show status line set ruler " Show the line and column number of the cursor position set showcmd " Show (partial) command in status line set splitbelow " Put the new window below the current one set title " Set title to the value of 'titlestring' or to "VIM - filename" set winheight=4 " At least 4 lines for current window set winminheight=0 " Allow zero-height windows set ts=4 " Text settings set autowrite " automatically save. set ttymouse=xterm " use mouse set noautoindent " Do not copy indent from current line when starting a new line set number " set number of lines. set backspace=2 " Backspace over indent, eol, start set expandtab " Do not insert tab when was pressed - insert a number of spaces set nojoinspaces " Do not insert two spaces after a '.', '?' and '!' with a join command set notextmode " Don't append bloody carriage returns set shiftwidth=3 " Number of spaces to use for each step of (auto)indent set softtabstop=3 " Number of spaces that a counts for while performing editing operations set tabstop=8 " Number of spaces that a in the file counts for set textwidth=72 " Maximum width of text that is being inserted. A longer line will be broken. Zero disables this. " Search settings "set ignorecase " Ignore case in search patterns set incsearch " Incremental search. Beware! Only for fast terminals set nohlsearch " Stop the search highlighting " for 2html let html_number_lines = 0 let html_use_css = 1 " Comment: Run from a Unix shell " Comment: " for f in *.[ch]; do gvim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" $f; done " " TERMINALS, MICE and COLORS "set ttyfast " Indicates a fast terminal connection set mouse=ar " Use mouse in all modes, plus hit-return " Set beahviour to xterm, not mswin behave xterm if has("gui_running") " set background=Black else if (&term =~ "term") || (&term =~ "rxvt") || (&term =~ "vt100") || (&term =~ "screen") " Use the clipboard register '*' for all yank, delete and put operations. " This allows to use mouse for copy/paste in local xterm, " but prevents to save the unnamed register between sessions set clipboard=unnamed if has ("terminfo") " set t_Co=8 " set t_Sf=[3%p1%dm " set t_Sb=[4%p1%dm set t_Co=16 set t_AF=[%?%p1%{8}%<%t3%p1%d%e%p1%{22}%+%d;1%;m set t_AB=[%?%p1%{8}%<%t4%p1%d%e%p1%{32}%+%d;1%;m " ^ this must be real Escape else set t_Co=8 set t_Sf=[3%dm set t_Sb=[4%dm endif endif " Set background to dark to have nicer syntax highlighting. set background=dark endif " And of course, the ever important syntax highlighting " This has to go last because of the if stuff above syntax on " Status line is bright white on blue; please note fg/bg is reverse for term mode highlight StatusLine cterm=bold ctermfg=white ctermbg=blue " AUTOCOMMANDS " enable filetype detection: filetype on " Remove all autocommands. "autocmd! " When editing a file, always jump to the last cursor position autocmd BufReadPost * if line("'\"") | exe "normal `\"" | endif " Set options for python files autocmd FileType python set autoindent smartindent \ cinwords=class,def,elif,else,except,finally,for,if,try,while \ makeprg=compyle4vim.py \ errorformat=%E\ \ File\ \"%f\"\\,\ line\ %l\\,\ column\ %c,%C%m | \ execute "autocmd BufWritePost " . expand("%") . " call DoPython()" " Compile (clearing *.cgi[co] files after compilation) " and if it is script, make it executable function DoPython() !compyle % if expand("%:e") != "py" !rm -f %[co] endif if getline(1) =~ "^#!" !chmod +x % endif endfunction " Set options for text/html files autocmd BufReadPre *.txt,*README*,*.htm*,/tmp/pico.*,mutt-* set textwidth=75 autocmd BufReadPre /tmp/pico.*,mutt-* set filetype=mail autocmd FileType css set smartindent " in makefiles, don't expand tabs to spaces, since actual tab characters are " needed, and have indentation at 8 chars to be sure that all indents are tabs " (despite the mappings later): autocmd FileType make set noexpandtab shiftwidth=8 " I like highlighting strings inside C comments let c_comment_strings=1 augroup gzip " Remove all gzip autocommands au! " Enable editing of gzipped files " read: set binary mode before reading the file " uncompress text in buffer after reading " write: compress file after writing " append: uncompress file, append, compress file autocmd BufReadPre,FileReadPre *.gz set bin autocmd BufReadPost,FileReadPost *.gz let ch_save = &ch|set ch=2 autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip autocmd BufReadPost,FileReadPost *.gz set nobin autocmd BufReadPost,FileReadPost *.gz let &ch = ch_save|unlet ch_save autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . expand("%:r") autocmd BufWritePost,FileWritePost *.gz !mv :r autocmd BufWritePost,FileWritePost *.gz !gzip :r autocmd FileAppendPre *.gz !gunzip autocmd FileAppendPre *.gz !mv :r autocmd FileAppendPost *.gz !mv :r autocmd FileAppendPost *.gz !gzip :r augroup END augroup bzip2 " Remove all bzip2 autocommands au! " Enable editing of bzipped files " read: set binary mode before reading the file " uncompress text in buffer after reading " write: compress file after writing " append: uncompress file, append, compress file autocmd BufReadPre,FileReadPre *.bz2 set bin autocmd BufReadPost,FileReadPost *.bz2 let ch_save = &ch|set ch=2 autocmd BufReadPost,FileReadPost *.bz2 '[,']!bunzip2 autocmd BufReadPost,FileReadPost *.bz2 set nobin autocmd BufReadPost,FileReadPost *.bz2 let &ch = ch_save|unlet ch_save autocmd BufReadPost,FileReadPost *.bz2 execute ":doautocmd BufReadPost " . expand("%:r") autocmd BufWritePost,FileWritePost *.bz2 !mv :r autocmd BufWritePost,FileWritePost *.bz2 !bzip2 :r autocmd FileAppendPre *.bz2 !bunzip2 autocmd FileAppendPre *.bz2 !mv :r autocmd FileAppendPost *.bz2 !mv :r autocmd FileAppendPost *.bz2 !bzip2 :r augroup END " MAPPINGS " Make # keep it's normal indentation so it works as a comment inoremap # X# " mappings: " map " map " map :shell " Make shift-insert work like in Xterm " map " map! if has("gui_running") " Send current file to a browser map ,b :!mozilla -remote 'openURL(file://%:p,new-window)'mozilla 'file://%:p'& " Send visual block to a browser vmap ,B "*y:!mozilla -remote 'openURL(*)'mozilla '*'& else " send current file to links map ,b :set isk+=:,/,.,~:!links %:set isk-=:,/,.,~ " send link to links map ,B :set isk+=:,/,.,~:!links :set isk-=:,/,.,~ endif autocmd BufRead /tmp/mutt* :source ~/.vim.mail