parts from the books, parts from tips...
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set autoindent " always set autoindenting on
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set nohlsearch
endif
" Only do this part when compiled with support for autocommands.
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
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
endif " has("autocmd")
set showmode
version 6.0
set nocompatible
let s:cpo_save=&cpo
set cpo&vim
map! <xHome> <Home>
map! <xEnd> <End>
map! <S-xF4> <S-F4>
map! <S-xF3> <S-F3>
map! <S-xF2> <S-F2>
map! <S-xF1> <S-F1>
map! <xF4> <F4>
map! <xF3> <F3>
map! <xF2> <F2>
map! <xF1> <F1>
map Q gq
map <xHome> <Home>
map <xEnd> <End>
map <S-xF4> <S-F4>
map <S-xF3> <S-F3>
map <S-xF2> <S-F2>
map <S-xF1> <S-F1>
map <xF4> <F4>
map <xF3> <F3>
map <xF2> <F2>
map <xF1> <F1>
map ; :set invhls<CR>
let &cpo=s:cpo_save
unlet s:cpo_save
set smartindent
set cin
set background=dark
set mouse=a
set foldmethod=marker
set showtabline=2
set foldcolumn=1
set fillchars=fold:=
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-L> <Right>
cnoremap <C-H> <Left>
cnoremap <Esc>b <S-Left>
cnoremap <Esc>w <S-Right>
cnoremap <Esc>$ <End>
cnoremap <Esc>^ <Home>
cnoremap <Esc>k <Up>
cnoremap <Esc>j <Down>
set modifiable
set laststatus=2
colorscheme desert
set ignorecase
set linebreak
set display=lastline
set shiftwidth=2
set statusline=[%02n]\ %(%M%R%H%)\ %F\ %=%{getcwd()}\ <%l,%c%V>\ %P
map <F5> <ESC>:wa<Enter>:mks! current.vim<Enter>
map <F6> <ESC>:so current.vim<Enter>
set autoread
" set your working directory to the file you're editing
function! CD()"{{{
let _dir = expand("%:p:h")
exec "cd " . _dir
unlet _dir
endfunction"}}}
call CD()
"****************
" In Makefile, automatically convert eight spaces at the beginning
" of line to tab, as you type (or paste)
"*****************
au FileType make :inoremap <buffer><silent><space> <space><c-o>:call MapSpaceInMakefile()<cr>
" function! MapSpaceInMakefile() "{{{
function! MapSpaceInMakefile()
" if this space is 8th space from the beginning of line, replace 8 spaces with
" one tab (only at the beginning of file)
let line = getline('.')
let col = col('.')
if strpart(line, 0, 8) == ' '
let new = "\t" . strpart(line,8)
call setline('.', new )
endif
return ""
endfunction
"}}}
vnoremap <C-X> <Esc>`.``gvP``P
map <C-J> <C-W>j
map <C-K> <C-W>k
imap <C-J> <ESC><C-W>j
imap <C-K> <ESC><C-W>k
imap <C-H> <ESC><C-W>h
imap <C-L> <ESC><C-W>l
map <C-H> <C-W>h
map <C-L> <C-W>l
map <S-Right> :tabnext<CR>
map <S-Left> :tabprevious<CR>
imap <S-Right> <ESC>:tabnext<CR>
imap <S-Left> <ESC>:tabprevious<CR>
nn <C-RIGHT> :if tabpagenr() == tabpagenr("$")\|tabm 0\|el\|exe "tabm ".tabpagenr()\|en<CR>
nn <C-LEFT> :if tabpagenr() == 1\|exe "tabm ".tabpagenr("$")\|el\|exe "tabm ".(tabpagenr()-2)\|en<CR>
set wmh=0
imap <S-Right> ->
map <C-n> :cn<CR>
map <C-p> :cp<CR>
map ; :set invhls<CR>
set wildmode=full
set wildmenu
set wildcharm=<C-Z>
map <C-H> <C-W>h
map <C-J> <C-W>j
map <C-K> <C-W>k
map <C-L> <C-W>l
map <C-C> <C-W>c
imap <C-H> <ESC><C-W>h
imap <C-J> <ESC><C-W>j
imap <C-K> <ESC><C-W>k
imap <C-L> <ESC><C-W>l
imap <C-C> <ESC><C-W>c
map \i <ESC>magg=G'azz
map <A-DOWN> gj
map <A-UP> gk
imap <A-UP> <ESC>gki
imap <A-DOWN> <ESC>gji
noremap <S-UP> <UP>
noremap <S-DOWN> <DOWN>
inoremap <S-UP> ->
inoremap <S-DOWN> ->
vnoremap > >gv
vnoremap < <gv
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" don't go to next one, just start the search
nnoremap <silent> * :let @/='\<'.expand("<cword>").'\>' <bar> set hlsearch<CR>