264 lines
7.2 KiB
VimL
Executable File
264 lines
7.2 KiB
VimL
Executable File
"source $VIMRUNTIME/vimrc_example.vim
|
||
"source $VIMRUNTIME/mswin.vim
|
||
"behave mswin
|
||
|
||
if has("multi_byte")
|
||
if &termencoding == ""
|
||
let &termencoding = &encoding
|
||
endif
|
||
set encoding=utf-8
|
||
setglobal fileencoding=utf-8
|
||
"setglobal bomb
|
||
set fileencodings=ucs-bom,utf-8,latin1
|
||
endif
|
||
|
||
set nocompatible " Use Vim defaults (much better!)
|
||
set backspace=indent,eol,start " allow backspacing over everything in insert mode
|
||
"set bs=2 " allow backspacing over everything in insert mode
|
||
"set backup " keep a backup file
|
||
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
|
||
" than 50 lines of registers
|
||
set history=50 " keep 50 lines of command line history
|
||
set ruler " show the cursor position all the time
|
||
set tabstop=4 " make tabes to be equal to 4 space chars.
|
||
set shiftwidth=4 " for indentation shift by 4 chars.
|
||
set noexpandtab " don't expand tabs. For MG devel/mg/.vimrc sets expandtab.
|
||
set softtabstop=4 " insert/<BS> deletes 4 space chars.
|
||
set smarttab " insert/<BS> space in front of line instead of tab.
|
||
set fileformat=unix " line ending is unix
|
||
set textwidth=80 " 80 char text
|
||
let g:netrw_preview = 1 " netrw open window to the right
|
||
let g:netrw_browse_split = 3 " open in a tab
|
||
|
||
" In many terminal emulators the mouse works just fine, thus enable it.
|
||
if has('mouse')
|
||
set mouse=a
|
||
endif
|
||
|
||
" a copy-past from my linux vimrc
|
||
if &term=="xterm"
|
||
set t_Co=8
|
||
set t_Sb=[4%dm
|
||
set t_Sf=[3%dm
|
||
endif
|
||
|
||
" 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 hlsearch
|
||
"
|
||
" This will turn on svrf highlighting
|
||
au BufRead,BufNewFile *.svrf set filetype=calibre
|
||
endif
|
||
|
||
" One such option is the 'hidden' option, which allows you to re-use the same
|
||
" window and switch from an unsaved buffer without saving it first. Also allows
|
||
" you to keep an undo history for multiple files when re-using the same window
|
||
" in this way. Note that using persistent undo also lets you undo in multiple
|
||
" files even in the same window, but is less efficient and is actually designed
|
||
" for keeping undo history after closing Vim entirely. Vim will complain if you
|
||
" try to quit without saving, and swap files will keep you safe if your computer
|
||
" crashes.
|
||
if exists('&hidden')
|
||
set hidden
|
||
endif
|
||
|
||
" Instead of failing a command because of unsaved changes, raise a dialogue
|
||
" asking if you wish to save changed files.
|
||
if exists('&confirm')
|
||
set confirm
|
||
endif
|
||
|
||
" Use visual bell instead of beeping when doing something wrong
|
||
if exists('&visualbell')
|
||
set visualbell
|
||
endif
|
||
|
||
" Display line numbers on the left
|
||
if exists('&number')
|
||
set number
|
||
endif
|
||
|
||
" Turn on spell check.
|
||
if exists("+spell")
|
||
set spell
|
||
endif
|
||
|
||
" Show 80th column.
|
||
if exists("+colorcolumn")
|
||
set colorcolumn=+1 " color textwidth+1-th line
|
||
endif
|
||
|
||
" Modelined are used to configure files.
|
||
if exists('&modeline')
|
||
set modeline
|
||
set modelines=10
|
||
endif
|
||
|
||
" Set fold method if supported
|
||
if has('folding')
|
||
set nofoldenable
|
||
set foldmethod=indent "fold based on indent
|
||
set foldnestmax=5
|
||
set foldlevel=1
|
||
if has("autocmd")
|
||
autocmd FileType vim setlocal foldmethod=marker
|
||
autocmd FileType c setlocal foldmethod=syntax
|
||
autocmd FileType h setlocal foldmethod=syntax
|
||
autocmd FileType cpp setlocal foldmethod=syntax
|
||
endif
|
||
endif
|
||
|
||
" Unset expandtab for make files in any case.
|
||
if has('autocmd')
|
||
autocmd FileType make setlocal noexpandtab
|
||
endif
|
||
|
||
" Set expandtab for python files in any case.
|
||
if has('autocmd')
|
||
autocmd FileType python setlocal expandtab
|
||
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
|
||
|
||
" Put these in an autocmd group, so that we can delete them easily.
|
||
augroup vimrcEx
|
||
au!
|
||
|
||
" For all text files set 'textwidth' to 78 characters.
|
||
autocmd FileType text setlocal textwidth=79
|
||
|
||
" 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).
|
||
" Also don't do it when the mark is in the first line, that is the default
|
||
" position when opening a file.
|
||
autocmd BufReadPost *
|
||
\ if line("'\"") > 1 && line("'\"") <= line("$") |
|
||
\ exe "normal! g`\"" |
|
||
\ endif
|
||
|
||
augroup END
|
||
|
||
else
|
||
set autoindent " always set autoindenting on
|
||
endif " has("autocmd")
|
||
|
||
" Convenient command to see the difference between the current buffer and the
|
||
" file it was loaded from, thus the changes you made.
|
||
" Only define it when not defined already.
|
||
if !exists(":DiffOrig")
|
||
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
|
||
\ | wincmd p | diffthis
|
||
endif
|
||
|
||
set diffexpr=MyDiff()
|
||
function MyDiff()
|
||
let opt = '-a --binary '
|
||
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
|
||
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
|
||
let arg1 = v:fname_in
|
||
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
|
||
let arg2 = v:fname_new
|
||
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
|
||
let arg3 = v:fname_out
|
||
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
|
||
let eq = ''
|
||
if $VIMRUNTIME =~ ' '
|
||
if &sh =~ '\<cmd'
|
||
let cmd = '""' . $VIMRUNTIME . '\diff"'
|
||
let eq = '"'
|
||
else
|
||
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
|
||
endif
|
||
else
|
||
let cmd = $VIMRUNTIME . '\diff'
|
||
endif
|
||
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
|
||
endfunction
|
||
|
||
" Don't let vim be too smart.
|
||
set formatoptions=cql
|
||
"
|
||
" P4
|
||
command! -nargs=* PFedit :!p4 edit <args> %
|
||
command! -nargs=* PFrevert :!p4 revert <args> %
|
||
command! -nargs=* PFdiff :!p4 diff <args> %
|
||
"
|
||
" Loads CF5Compile
|
||
" Compile and run file if Ctrl-F5 is pressed.
|
||
"
|
||
if !exists('*CF5Compile')
|
||
runtime plugin/cf5-compiler.vim
|
||
endif
|
||
map <silent> <C-F5> :call CF5Compile(1)<CR>
|
||
map <silent> <F5> :call CF5Compile(0)<CR>
|
||
"
|
||
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
|
||
" so that you can undo CTRL-U after inserting a line break.
|
||
"
|
||
inoremap <C-U> <C-G>u<C-U>
|
||
"
|
||
" Move through wrapped lines instead of buffer lines.
|
||
"
|
||
noremap <Up> gk
|
||
noremap <Down> gj
|
||
imap <Up> <C-O>gk
|
||
imap <Down> <C-O>gj
|
||
"
|
||
" Working with tabs especially if using Putty.
|
||
"
|
||
nnoremap th :tabfirst<CR>
|
||
nnoremap tj :tabnext<CR>
|
||
nnoremap tk :tabprev<CR>
|
||
nnoremap tl :tablast<CR>
|
||
nnoremap tm :tabm<Space>
|
||
nnoremap td :tabclose<CR>
|
||
"
|
||
" .gvimrc content here.
|
||
"
|
||
if has("gui_running")
|
||
|
||
colors darkblue " set color scheme
|
||
set lines=50
|
||
set columns=85
|
||
if has("win32") || has("win64")
|
||
set guifont=FreeMono:h14:cANSI
|
||
"set guifont=Courier\ AM:h12
|
||
endif
|
||
|
||
|
||
":tab drop {file}
|
||
|
||
" Hide show menu and toolbar.
|
||
map <silent> <C-F2> :if &guioptions =~# 'm' <Bar>
|
||
\set guioptions-=m <Bar>
|
||
\set guioptions-=T <Bar>
|
||
\set showtabline=0 <Bar>
|
||
\else <Bar>
|
||
\set guioptions+=m <Bar>
|
||
\set guioptions+=T <Bar>
|
||
\set showtabline=1 <Bar>
|
||
\endif <CR>
|
||
|
||
" Open file in a new tab.
|
||
if has("browsefilter")
|
||
let g:browsefilter = "All Files (*.*)\t*\n"
|
||
endif
|
||
"if has("browse")
|
||
map <silent> <C-F3> :browse tabnew %:p:h<CR>
|
||
"endif
|
||
|
||
else
|
||
colors vahagn_black_terminal
|
||
endif
|
||
|