Skip to content

Instantly share code, notes, and snippets.

@mamantoha
Created March 7, 2012 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamantoha/1994183 to your computer and use it in GitHub Desktop.
Save mamantoha/1994183 to your computer and use it in GitHub Desktop.
.vimrc
set nocompatible "don't need to keep compatibility with Vi
filetype plugin indent on "enable detection, plugins and indenting in one step
syntax on "Turn on syntax highlighting
set cursorline "underline the current line in the file
set cursorcolumn "highlight the current column. Visible in GUI mode only.
set fileencodings=utf-8,cp1251,cp866,koi8-u
set encoding=utf-8
set termencoding=utf-8
set statusline=%t\ %y%m%r[%{&fileencoding}][%{&spelllang}][%{&fileformat}]%<[%{strftime(\"%d.%m.%y\",getftime(expand(\"%:p\")))}]%k%=%-14.(%l,%c%V%)\ %P
set laststatus=2
colorscheme desert
" Підтримка мишки
"set mouse=a
"set mousemodel=popup
set shiftwidth=2 "number of spaces to use in each autoindent step
set tabstop=2 "two tab spaces
set softtabstop=2 "number of spaces to skip or insert when <BS>ing or <Tab>ing
set expandtab "spaces instead of tabs for better cross-editor compatibility
set smarttab "use shiftwidth and softtabstop to insert or delete (on <BS>) blanks
set cindent "recommended seting for automatic C-style indentation
set autoindent "automatic indentation in non-C files
set nowrap "no wrapping
set copyindent "copy the previous indentation on autoindenting
set backspace=indent,eol,start "allow backspacing over everything in insert mode
set incsearch "find the next match as we type the search
set hlsearch "hilight searches by default
set ignorecase "ignore case when searching
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
set number "Show line numbers
" Пробіл в нормальному режимі перелистує сторінки
nmap <Space> <PageDown>
" Ukrainian support | CTRL+^
set keymap=ukrainian-jcuken
" by default - latin keymap
set iminsert=0
" by default - latin keymap for search
set imsearch=0
" F2 - швидке зберігання
nmap <F2> :w<cr>
vmap <F2> <esc>:w<cr>i
imap <F2> <esc>:w<cr>i
" <F7> File fileformat (dos - <CR> <NL>, Unix - <NL>, mac - <CR>)
map <F7> :execute RotateFileFormat()<CR>
vmap <F7> <C-C><F7>
imap <F7> <C-O><F7>
let b:fformatindex=0
function! RotateFileFormat()
let y = -1
while y == -1
let encstring = "#unix#dos#mac#"
let x = match(encstring,"#",b:fformatindex)
let y = match(encstring,"#",x+1)
let b:fformatindex = x+1
if y == -1
let b:fformatindex = 0
else
let str = strpart(encstring,x+1,y-x-1)
return ":set fileformat=".str
endif
endwhile
endfunction
" <F8> File encoding for open
" ucs-2le - MS Windows Unicode encoding
map <F8> :execute RotateEnc()<CR>
vmap <F8> <C-C><F8>
imap <F8> <C-O><F8>
let b:encindex=0
function! RotateEnc()
let y = -1
while y == -1
let encstring = "#koi8-r#cp1251#8bit-cp866#utf-8#ucs-2le#"
let x = match(encstring,"#",b:encindex)
let y = match(encstring,"#",x+1)
let b:encindex = x+1
if y == -1
let b:encindex = 0
else
let str = strpart(encstring,x+1,y-x-1)
return ":e ++enc=".str
endif
endwhile
endfunction
" <Shift+F8> Force file encoding for open (encoding = fileencoding)
map <S-F8> :execute ForceRotateEnc()<CR>
vmap <S-F8> <C-C><S-F8>
imap <S-F8> <C-O><S-F8>
let b:encindex=0
function! ForceRotateEnc()
let y = -1
while y == -1
let encstring = "#koi8-r#cp1251#8bit-cp866#utf-8#ucs-2le#"
let x = match(encstring,"#",b:encindex)
let y = match(encstring,"#",x+1)
let b:encindex = x+1
if y == -1
let b:encindex = 0
else
let str = strpart(encstring,x+1,y-x-1)
:execute "set encoding=".str
return ":e ++enc=".str
endif
endwhile
endfunction
" <Ctrl+F8> File encoding for save (convert)
map <C-F8> :execute RotateFEnc()<CR>
vmap <C-F8> <C-C><C-F8>
imap <C-F8> <C-O><C-F8>
let b:fencindex=0
function! RotateFEnc()
let y = -1
while y == -1
let encstring = "#koi8-r#cp1251#8bit-cp866#utf-8#ucs-2le#"
let x = match(encstring,"#",b:fencindex)
let y = match(encstring,"#",x+1)
let b:fencindex = x+1
if y == -1
let b:fencindex = 0
else
let str = strpart(encstring,x+1,y-x-1)
return ":set fenc=".str
endif
endwhile
endfunction
" F9 - зміна кодування файлу
set wildmenu
set wcm=<Tab>
menu Encoding.koi8-u :e ++enc=koi8-u<CR>
menu Encoding.windows-1251 :e ++enc=cp1251<CR>
menu Encoding.ibm-866 :e ++enc=ibm866<CR>
menu Encoding.utf-8 :e ++enc=utf-8 <CR>
map <F9> :emenu Encoding.<TAB>
" ftp://ftp.vim.org/pub/vim/runtime/spell/
if version >= 700
" По замовчуванню перевірка орфографії виключена.
setlocal spell spelllang=
setlocal nospell
function ChangeSpellLang()
if &spelllang == "en_us"
setlocal spell spelllang=ru
elseif &spelllang == "ru"
setlocal spell spelllang=uk
elseif &spelllang == "uk"
setlocal spell spelllang=
setlocal nospell
else
setlocal spell spelllang=en_us
endif
endfunc
" map spell on/off
map <F11> <Esc>:call ChangeSpellLang()<CR>
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment