[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Настройка Vim и работа в нём.



Поделитесь вашими vimrc и полезными советами по настройке и работе в Vim.
Интересно всё.
Хочется конфиг, который будет работать и на windows и на unix-подобных.
Пока что, сделал немного (я эпизодически в конфиге ковыряюсь) и не организованно.
Вот, моё, уж что есть:
" Vim editor configuration: vimrc file.
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"        for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"      for OpenVMS:  sys$login:.vimrc

" 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

" 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
" set syntax=auto

" Проверка орфографии
set spell spelllang=en,ru
" Игнорировать регистр букв при поиске
set ignorecase
" Don't say me, that file has changed since editing started
set autoread
set mouse=a
" Mouse, like M$ windows
set mousemodel=popup
" For the correct GPM switch function work
set paste
 " Перенос по словам
set linebreak
"set ttymouse=

" Переключение раскладок клавиатуры по <C-^>
" set keymap=russian-jcukenwin
" Раскладка по умолчанию - английская
set iminsert=0

" Отступы
set tabstop=3
set shiftwidth=3
set smartindent
" Tab to spaces
set expandtab

" Отображение дополнительной информации в статусной строке
set statusline=%<%f%h%m%r%=format=%{&fileformat}\ file=%{&fileencoding}\
enc=%{&encoding}\ %b\ 0x%B\ %l,%c%V\ %P
set laststatus=2   " всегда показывать строку статуса

" Список кодировок файлов для автоопределения
set fileencodings=utf-8,cp1251,cp866,koi8-r

" GUI
if has("gui_win32") || has("win32")
   set guifont=Monospace\ 12
else
   set guifont=Terminus\ 12
endif

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Mapping keys
" set
langmap=йq,цw,уe,кr,еt,нy,гu,шi,щo,зp,х[,ъ],фa,ыs,вd,аf,пg,рh,оj,лk,дl,яz,чx,сc,мv,иb,тn,ьm,ЙQ,ЦW,УE,КR,ЕT,НY,ГU,ШI,ЩO,ЗP,ФA,ЫS,ВD,АF,ПG,РH,ОJ,ЛK,ДL,ЯZ,ЧX,СC,МV,ИB,ТN,ЬM
map Q wq
map ж ;
map Ж :
map э '
map Э "
map б ,
map Б <
map ю .
map Ю >
map ё `
map Ё ~

"""""""""
" 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 hlsearch
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 on
  filetype plugin on
"  filetype plugin indent off
"  set autoindent=off      " always set autoindenting on(ff)
   " always set autoindenting on(ff)
   set autoindent

   "set nocindent
   " Отступы для программ на C.
   set cino=e0p0}0(0)0

"
  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

   augroup Binary
   " vim -b : edit binary using xxd-format!
   au!
   au BufReadPre  *.bin,*.exe,*.com,*.dll let &bin=1
   au BufReadPost *.bin,*.exe,*.com,*.dll if &bin | %!xxd
   au BufReadPost *.bin,*.exe,*.com,*.dll set ft=xxd | endif
   au BufWritePre *.bin,*.exe,*.com,*.dll if &bin | %!xxd -r
   au BufWritePre *.bin,*.exe,*.com,*.dll endif
   au BufWritePost *.bin,*.exe,*.com,*.dll if &bin | %!xxd
   au BufWritePost *.bin,*.exe,*.com,*.dll set nomod | endif
  augroup END
  " Просмотр нетекстовых файлов в Vim
  au BufReadPost *.pdf silent %!pdftotext -nopgbrk "%" - |fmt -csw78
  au BufReadPost *.doc silent %!wvWare -1 -x /usr/share/wv/wvText.xml "%"
  au BufReadPost *.odt silent %!wvWare -1 -x /usr/share/wv/wvText.xml "%"
"  au BufReadPost *.rtf silent %!wvWare -1 -x /usr/share/wv/wvText.xml "%"
  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType awk     compiler awk
  autocmd FileType csh     compiler csh
  autocmd FileType c       compiler gcc
  autocmd FileType cpp     compiler gcc
  autocmd FileType fortran compiler fortran_g77
  "autocmd FileType make      compiler make
  autocmd FileType perl    compiler perl
  autocmd FileType python  compiler pyunit
  autocmd FileType ruby    compiler ruby
  autocmd FileType java    compiler gcc
  "autocmd FileType sh     compiler shell
  autocmd FileType tcl     compiler tcl
  autocmd FileType tcsh    compiler csh
  autocmd FileType zsh     compiler zsh
  autocmd FileType binary  fil

  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

  augroup END

else

endif " has("autocmd")

" My functions

 function! BaloonDict()
   let s:phrase = v:beval_text
   if match(s:phrase, '\c[a-zа-я]') != -1
      return system('dict "'.s:phrase.'"')
   endif
   return ""
 endfunction

set bexpr=BaloonDict()
set ballooneval
set balloondelay=150

 function Spellchk(lang)
	try
      w!
      if a:lang == "-" && $SPELL_LANG == ""
         let $SPELL_LANG="en"
       elseif a:lang != "-"
         let $SPELL_LANG=a:lang
      endif
      !aspell -l "$SPELL_LANG" -c %
      %d " Delete in buffer, it's for 'u'
      r %
      1d " Delete added blank string
   catch /*/
      return 1
   endtry
 endf

 function Translate()
   " !socrat <cWORD>
   !dict <cWORD>
 endf

 function Auto_recode()
   w!
   split
   r !enconv -L russian - < % 2>/dev/null
	" !xcode % > %.recode
 endf

 function Mousec(arg)
   if (a:arg == "auto" && &paste) || a:arg == "off"
      set nopaste
      set mouse=
      ec "gpm [off]"
   else
      set paste
      set mouse=a
      set modifiable
      ec "gpm [on]"
   endif
 endfu

" Some macroses
 command Date read !echo -en "\c`date`\c"
 command -nargs=* Spell call Spellchk(<args>)
 command Slr Spell("ru")
 command Sle Spell("en")
 command Recode call Auto_recode()
 command -nargs=1 Mouse call Mousec(<f-args>)
 map <F2> :set wrap!<CR>
 map! <F2> <ESC>:set wrap!<CR>
 map <C-F2> :set ballooneval!<CR>
 map! <C-F2> :set ballooneval!<CR>
 map <F3> :set number!<CR>
 map <F4> :call Translate()<CR>
 map! <F4> <ESC>:call Translate()<CR>
 map <F5> :Date<CR>
 map <F6> :Slr<CR>
 map <F7> :Recode<CR>
 map <F8> :read !date<CR>
 map! <F8> <ESC>:read !date<CR>
 map <F9> :emenu <C-Z>
 map <F12> :Mouse auto<CR>
" Colors

 colorscheme evening
" colorscheme delek
" colorscheme torte
" colorscheme default_light

" Menus
" source $VIMRUNTIME/menu.vim
" set wildmenu cpo-=< wcm=<C-Z>


Reply to: