The configuration file vim -. Vimrc (for Linux and Windows)
I will continue the preservation of the most interesting of its configuration files. Today was the turn of the configuration file for the editor vim -. Vimrc. Quite a lot of time devoted to it, collecting and sharing the settings of their application for different operating systems (Windows and Linux). And will he finally completed - do not even know ![]()
The best thing about the Russian-speaking guide (with examples) for setting up of Vim I met on the Internet: Another HowTo for Vim .
"Look and BASIC SETTINGS EDITOR
" отключить режим совместимости с классическим Vi set nocompatible "disable compatibility mode with the classic Vi
" включить подсветку синтаксиа syntax on "turn on the backlight syntactic
" определять подсветку на основе кода файла filetype plugin indent on "to determine the backlight based on the code file
= 3 " сколько строк внизу и вверху экрана показывать при скроллинге set scrolloff = 3 "number of lines at the bottom and top of the screen display when scrolling
=dark " установить цвет фона set background = dark "set background color
colorscheme af "the default color scheme (if you enter a command mode for tab completion schema names available)
" перенос длинных строк set wrap "long lines of transport
" переносить целые слова set lbr "whole words transfer
" не выгружать буфер когда переключаешься на другой set hidden "do not unload buffer when switching to another
=a " включает поддержку мыши при работе в терминале (без GUI) set mouse = a "includes mouse support when running in a terminal (no GUI)
" скрывать мышь в режиме ввода текста set mousehide "hide mouse in text mode
" показывать незавершенные команды в статусбаре (автодополнение ввода) set showcmd "display incomplete commands in the status bar (autocomplete input)
+ = <:> " показывать совпадающие скобки для HTML-тегов set matchpairs + = <:> "show matching brackets for HTML-tags
" показывать первую парную скобку после ввода второй set showmatch "display the first brace after entering the second
" перечитывать изменённые файлы автоматически set autoread "to reread the changed files automatically
" использовать больше цветов в терминале set t_Co = 256 "to use more colors in the terminal
set confirm "dialogs to use instead of error messages
"" Automatically re-read the configuration VIM after saving
bufwritepost $ MYVIMRC source $ MYVIMRC autocmd! bufwritepost $ MYVIMRC source $ MYVIMRC
"" The format of the status bar
= 2 " всегда показывать строку состояния set laststatus = 2 "always show the status bar
"" Highlight tabs and trailing spaces
" включить подсветку set list "turn on the backlight
=tab :>- ,trail :- " установить символы, которыми будет осуществляться подсветка set listchars = tab:> -, trail: - "to set the characters that will be highlighting
"" Jump to the last place at the opening of the buffer
bufreadpost * call LastPosition ( ) autocmd! bufreadpost * call LastPosition ()
LastPosition ( ) function! LastPosition ()
( "' \" " ) && line ( "' \" " ) < = line ( '$' ) if line ("'\" ") & & line ("' \ "") <= line ('$')
normal! `"
endif
endfunction
= indent , eol ,start " backspace обрабатывает отступы, концы строк set backspace = indent, eol, start "backspace handles indentation, line breaks
=curdir,buffers,tabpages " опции сессий - перейти в текущию директорию, использовать буферы и табы set sessionoptions = curdir, buffers, tabpages "sessions options - go to the current directory, use buffers and tabs
" не использовать своп-файл (в него скидываются открытые буферы) set noswapfile "do not use a swap file (it thrown off the open buffers)
=current set browsedir = current
" вместо писка бипером показывать это на экране set visualbell "instead of a peep show beeper is on the screen
"When you insert the fragment retains the indentation
= set pastetoggle =
"Preferences Search
" ics - поиск без учёта регистра символов set ignorecase "ics - search is case insensitive
" - если искомое выражения содержит символы в верхнем регистре - ищет с учётом регистра, иначе - без учёта set smartcase "- if the search expression contains uppercase characters - searches are case sensitive, otherwise - without
" подсветка результатов поиска set hls "highlight search results
" поиск фрагмента по мере его набора set incsearch "fragment search as you type
"SETTING Code Folding (Folding)
" включить фолдинг set foldenable "include folding
= syntax " определять блоки на основе синтаксиса файла set foldmethod = syntax "define blocks based on the syntax file
= 3 " показать полосу для управления сворачиванием set foldcolumn = 3 "strip show for the management of folding
= 1 " Первый уровень вложенности открыт, остальные закрыты set foldlevel = 1 "The first level of nesting is open, the other closed
" правильное сворачивание классов и функций Perl let perl_folding = 1 "correct folding classes and functions Perl
" правильное сворачивание классов и функций PHP let php_folding = 1 "correct folding classes and PHP functions
=all " автоматическое открытие сверток при заходе в них set foldopen = all "automatic opening of the package upon arrival in their
"Settings Indents
= 4 " размер отступов set shiftwidth = 4 "indentation size
= 3 " ширина табуляции set tabstop = 3 "width tabs
= 3 " ширина 'мягкого' таба set softtabstop = 3 "width" soft "tabs
" ai - включить автоотступы set autoindent "ai - enable autoindent
" ci - отступы в стиле С set cindent "ci - C-style indentation
" Преобразовать табуляцию в пробелы set expandtab "Convert tabs to spaces
" Умные отступы (например, автоотступ после {) set smartindent "Smart indentation (eg, auto-indent after {)
"For these types of files off replacing tabs with spaces and change the width of the indentation
crontab,fstab,make set noexpandtab tabstop = 8 shiftwidth = 8 au FileType crontab, fstab, make set noexpandtab tabstop = 8 shiftwidth = 8
"Configuring FILE
"Encoding the default editor (when you open all the files contained in this encoding)
( 'win32' ) if has ('win32')
=cp1251 set encoding = cp1251
else
=utf - 8 set encoding = utf - 8
=utf - 8 set termencoding = utf - 8
endif
=unix,dos,mac " формат файла по умолчанию (влияет на окончания строк) - будет перебираться в указанном порядке set ffs = unix, dos, mac "default file format (affecting line endings) - will move in that order
=utf - 8 ,cp1251,koi8 - r,cp866 " варианты кодировки файла по умолчанию (все файлы по умолчанию сохраняются в этой кодировке) set fencs = utf - 8, cp1251, koi8 - r, cp866 "encoding options for the default file (all files are stored by default in this encoding)
"" Use file types
filetype on
filetype plugin on
filetype indent on
сделать его исполняемым "" If you saved the file is a script - make it executable
BufWritePost * if getline ( 1 ) = ~ "^#!.*/bin/" | silent ! chmod a + x %| endif "" Au BufWritePost * if getline (1) = ~ "^#!.*/ bin / "| silent! Chmod a + x% | endif
"" When you open the file specified for a corresponding 'compiler'
BufEnter *. pl compiler perl autocmd! BufEnter *. pl compiler perl
"Environment variable settings
( 'win32' ) if has ('win32')
VIMRUNTIME = $ HOME . ' \P rograms \V im \v im72' let $ VIMRUNTIME = $ HOME. '\ P rograms \ V im \ v im72'
mswin . vim source $ VIMRUNTIME / mswin. vim
else
VIMRUNTIME = $ HOME . '/.vim' let $ VIMRUNTIME = $ HOME. '/. vim'
endif
"Appearance Settings
для Windows и Linux ) "" Set the font (for Windows and Linux)
( 'gui' ) if has ('gui')
( 'win32' ) if has ('win32')
=Lucida_Console : h10 : cRUSSIAN :: set guifont = Lucida_Console: h10: cRUSSIAN::
else
=Terminus\ 10 set guifont = Terminus \ 10
endif
endif
"" Maximize the editor window to full screen
( 'gui' ) if has ('gui')
=T " отключить меню в GUI set guioptions - = T "off the menu in the GUI
* : set lines = 99999 columns = 99999 au GUIEnter *: set lines = 99 999 columns = 99,999
endif
"Backup Settings
" включить сохранение резервных копий set backup "enable backups
bufwritepre * call BackupDir ( ) " сделаем резервную копию перед записью буффера на диск autocmd! bufwritepre * call BackupDir () "will make a backup before writing the buffer to disk
"" Save smart backups daily
BackupDir ( ) function! BackupDir ()
"Define a directory to save the backup
( 'win32' ) if has ('win32')
backupdir = $ VIMRUNTIME . ' \b ackup' let l: backupdir = $ VIMRUNTIME. '\ b ackup'
else
backupdir = $ VIMRUNTIME . '/backup/' . let l: backupdir = $ VIMRUNTIME. '/ backup /'.
expand ( '%:p:h' ) , '^' .$ HOME, '~' , '' ) \ Substitute (expand ('%: p: h'), '^'. $ HOME, '~','')
endif
"If the directory does not exist, create it recursively
isdirectory ( l : backupdir ) if! isdirectory (l: backupdir)
( l : backupdir , 'p' , 0700 ) call mkdir (l: backupdir, 'p', 0700)
endif
"Redefine the backup directory
amp;amp; backupdir =l : backupdir let & amp; amp; backupdir = l: backupdir
"Redefine the expansion of the backup file
amp;amp; backupext = strftime ( '~%Y-%m-%d~' ) let & amp; amp; backupext = strftime ('~% Y-% m-% d ~')
endfunction
"Settings toggle keyboard layouts
"" Taken from konishchevdmitry
=russian - jcukenwin " настраиваем переключение раскладок клавиатуры по <C-^> set keymap = russian - jcukenwin "set up the switching of the keyboard on <C-^>
= 0 " раскладка по умолчанию - английская set iminsert = 0 "by default layout - English
MyKeyMapHighlight ( ) function! MyKeyMapHighlight ()
amp;amp; iminsert == 0 " при английской раскладке статусная строка текущего окна будет серого цвета if & amp; amp; iminsert == 0 "in the English keyboard layout of the current window status bar will be gray
hi StatusLine ctermfg = Gray guifg = Gray
else "and in Russian - green.
hi StatusLine ctermfg = DarkGreen guifg = DarkGreen
endif
endfunction
" при старте Vim устанавливать цвет статусной строки call MyKeyMapHighlight () "when starting Vim set the color of the status bar
* : call MyKeyMapHighlight ( ) " при смене окна обновлять информацию о раскладках au WinEnter *: call MyKeyMapHighlight () "when you change the windows update information on layouts
C - F > < C -^> " использовать Ctrl+F для переключения раскладок cmap <silent> <C - F> <C - ^> "to use Ctrl + F to switch keyboard layouts
C - F > < C -^> X < Esc >: call MyKeyMapHighlight ( ) < CR > a < C - H > imap <silent> <C - F> <C - ^> X <Esc>: call MyKeyMapHighlight () <CR> a <C - H>
C - F > a < C -^> <Esc> : call MyKeyMapHighlight ( ) <CR> nmap <silent> <C - F> a <C - ^> <Esc>: call MyKeyMapHighlight () <CR>
C - F > < Esc > a < C -^> <Esc> : call MyKeyMapHighlight ( ) < CR > gv vmap <silent> <C - F> <Esc> a <C - ^> <Esc>: call MyKeyMapHighlight () <CR> gv
"Turning AVTODOPLNENIYA INPUT (omnifunct)
python set omnifunc =pythoncomplete#Complete autocmd FileType python set omnifunc = pythoncomplete # Complete
tt2html set omnifunc =htmlcomplete#CompleteTags autocmd FileType tt2html set omnifunc = htmlcomplete # CompleteTags
javascript set omnifunc =javascriptcomplete#CompleteJS autocmd FileType javascript set omnifunc = javascriptcomplete # CompleteJS
html set omnifunc =htmlcomplete#CompleteTags autocmd FileType html set omnifunc = htmlcomplete # CompleteTags
css set omnifunc =csscomplete#CompleteCSS autocmd FileType css set omnifunc = csscomplete # CompleteCSS
xml set omnifunc =xmlcomplete#CompleteTags autocmd FileType xml set omnifunc = xmlcomplete # CompleteTags
php set omnifunc =phpcomplete#CompletePHP autocmd FileType php set omnifunc = phpcomplete # CompletePHP
c set omnifunc =ccomplete#Complete autocmd FileType c set omnifunc = ccomplete # Complete
"Hotkeys
"F2 - save the file
w < cr > nmap <F2>: w <cr>
esc >: w < cr > i vmap <F2> <esc>: w <cr> i
esc >: w < cr > i imap <F2> <esc>: w <cr> i
"F5 - View a list of buffers
buffers < cr > nmap <F5> <Esc>: buffers <cr>
esc >: buffers < cr > vmap <F5> <esc>: buffers <cr>
esc >< esc >: buffers < cr > imap <F5> <esc> <esc>: buffers <cr>
"F6 - previous buffer
: bp < cr > map <F6>: bp <cr>
esc >: bp < cr > i vmap <F6> <esc>: bp <cr> i
esc >: bp < cr > i imap <F6> <esc>: bp <cr> i
"F7 - the next buffer
: bn < cr > map <F7>: bn <cr>
esc >: bn < cr > i vmap <F7> <esc>: bn <cr> i
esc >: bn < cr > i imap <F7> <esc>: bn <cr> i
"F9 - to save the file and start the compilation (make)
: w < cr >: make < cr > map <F9>: w <cr>: make <cr>
esc >: w < cr >: make < cr > i vmap <F9> <esc>: w <cr>: make <cr> i
esc >: w < cr >: make < cr > i imap <F9> <esc>: w <cr>: make <cr> i
"F10 - enable-disable the browser document structure (TagList)
: TlistToggle < cr > map <F10>: TlistToggle <cr>
esc >: TlistToggle < cr > vmap <F10> <esc>: TlistToggle <cr>
esc >: TlistToggle < cr > imap <F10> <esc>: TlistToggle <cr>
"F11 - turn on / off line numbering
set < Space > nu !< CR > a imap <F11> <Esc>: set <Space> nu! <CR> a
set < Space > nu ! <CR> nmap <F11>: set <Space> nu! <CR>
"F12 - File Browser (: Ex a standard browser plug-NERDTree -
"The directory tree)
: NERDTreeToggle < cr > map <F12>: NERDTreeToggle <cr>
esc >: NERDTreeToggle < cr > i vmap <F12> <esc>: NERDTreeToggle <cr> i
esc >: NERDTreeToggle < cr > i imap <F12> <esc>: NERDTreeToggle <cr> i
вкладок ) "" Switching tabs (tabs)
S - tab > : tabprevious < cr > map <S - tab>: tabprevious <cr>
tab > : tabprevious < cr > nmap <S - tab>: tabprevious <cr>
tab > < ESC >: tabprevious < cr > i imap <S - tab> <ESC>: tabprevious <cr> i
C - tab > : tabnext < cr > map <C - tab>: tabnext <cr>
tab > : tabnext < cr > nmap <C - tab>: tabnext <cr>
tab > < ESC >: tabnext < cr > i imap <C - tab> <ESC>: tabnext <cr> i
t > : tabnew < cr > nmap <C - t>: tabnew <cr>
t > < ESC >: tabnew < cr > imap <C - t> <ESC>: tabnew <cr>
w > : tabclose < cr > nmap <C - w>: tabclose <cr>
w > < ESC >: tabclose < cr > imap <C - w> <ESC>: tabclose <cr>
"" Changing the Encoding file
set wildmenu
= < Tab > set wcm = <Tab>
e ++ enc =cp1251 < CR > menu Encoding. CP1251: e + + enc = cp1251 <CR>
e ++ enc =cp866 < CR > menu Encoding. CP866: e + + enc = cp866 <CR>
U : e ++ enc =koi8 - u < CR > menu Encoding. KOI8 - U: e + + enc = koi8 - u <CR>
8 : e ++ enc =utf - 8 < CR > menu Encoding. UTF - 8: e + + enc = utf - 8 <CR>
: emenu Encoding .< TAB > map <F8>: emenu Encoding. <TAB>
"C (trl) + d - duplication of the current line
d > < esc > yypi imap <C - d> <esc> yypi
"Ctrl-Space for autocomplete
space > < C - x >< C - o > inoremap <C - space> <C - x> <C - o>
"Ce - comment / uncomment (by NERD_Comment)
C - e > , ci map <C - e>, ci
e > , ci nmap <C - e>, ci
e > < ESC > ,cii imap <C - e> <ESC>, cii
копировать - вставить через Ctrl "" Cut - Copy - Paste via Ctrl
X > "+x " CTRL - X - вырезать vnoremap <C - X> "+ x" CTRL - X - cut
C > "+y " CTRL - C - копировать vnoremap <C - C> "+ y" CTRL - C - copy
C - V > "+gP " CTRL - V вставить под курсором map <C - V> "+ gP" CTRL - V to insert under the cursor
вернуть через Ctrl "" Cancel - to return via Ctrl
C - Z > u " отмена действия noremap <C - Z> u "abolition of the
Z > < C - O > u inoremap <C - Z> <C - O> u
C - Y > < C - R > " вернуть отменённое назад noremap <C - Y> <C - R> "redo ago
Y > < C - O >< C - R > inoremap <C - Y> <C - O> <C - R>
" отключить режим совместимости с классическим Vi set nocompatible "disable compatibility mode with the classic Vi
" включить подсветку синтаксиа syntax on "turn on the backlight syntactic
" определять подсветку на основе кода файла filetype plugin indent on "to determine the backlight based on the code file
= 3 " сколько строк внизу и вверху экрана показывать при скроллинге set scrolloff = 3 "number of lines at the bottom and top of the screen display when scrolling
=dark " установить цвет фона set background = dark "set background color
colorscheme af "the default color scheme (if you enter a command mode for tab completion schema names available)
" перенос длинных строк set wrap "long lines of transport
" переносить целые слова set lbr "whole words transfer
" не выгружать буфер когда переключаешься на другой set hidden "do not unload buffer when switching to another
=a " включает поддержку мыши при работе в терминале (без GUI) set mouse = a "includes mouse support when running in a terminal (no GUI)
" скрывать мышь в режиме ввода текста set mousehide "hide mouse in text mode
" показывать незавершенные команды в статусбаре (автодополнение ввода) set showcmd "display incomplete commands in the status bar (autocomplete input)
+ = <:> " показывать совпадающие скобки для HTML-тегов set matchpairs + = <:> "show matching brackets for HTML-tags
" показывать первую парную скобку после ввода второй set showmatch "display the first brace after entering the second
" перечитывать изменённые файлы автоматически set autoread "to reread the changed files automatically
" использовать больше цветов в терминале set t_Co = 256 "to use more colors in the terminal
set confirm "dialogs to use instead of error messages
"" Automatically re-read the configuration VIM after saving
bufwritepost $ MYVIMRC source $ MYVIMRC autocmd! bufwritepost $ MYVIMRC source $ MYVIMRC
"" The format of the status bar
= 2 " всегда показывать строку состояния set laststatus = 2 "always show the status bar
"" Highlight tabs and trailing spaces
" включить подсветку set list "turn on the backlight
=tab :>- ,trail :- " установить символы, которыми будет осуществляться подсветка set listchars = tab:> -, trail: - "to set the characters that will be highlighting
"" Jump to the last place at the opening of the buffer
bufreadpost * call LastPosition ( ) autocmd! bufreadpost * call LastPosition ()
LastPosition ( ) function! LastPosition ()
( "' \" " ) && line ( "' \" " ) < = line ( '$' ) if line ("'\" ") & & line ("' \ "") <= line ('$')
normal! `"
endif
endfunction
= indent , eol ,start " backspace обрабатывает отступы, концы строк set backspace = indent, eol, start "backspace handles indentation, line breaks
=curdir,buffers,tabpages " опции сессий - перейти в текущию директорию, использовать буферы и табы set sessionoptions = curdir, buffers, tabpages "sessions options - go to the current directory, use buffers and tabs
" не использовать своп-файл (в него скидываются открытые буферы) set noswapfile "do not use a swap file (it thrown off the open buffers)
=current set browsedir = current
" вместо писка бипером показывать это на экране set visualbell "instead of a peep show beeper is on the screen
"When you insert the fragment retains the indentation
= set pastetoggle =
"Preferences Search
" ics - поиск без учёта регистра символов set ignorecase "ics - search is case insensitive
" - если искомое выражения содержит символы в верхнем регистре - ищет с учётом регистра, иначе - без учёта set smartcase "- if the search expression contains uppercase characters - searches are case sensitive, otherwise - without
" подсветка результатов поиска set hls "highlight search results
" поиск фрагмента по мере его набора set incsearch "fragment search as you type
"SETTING Code Folding (Folding)
" включить фолдинг set foldenable "include folding
= syntax " определять блоки на основе синтаксиса файла set foldmethod = syntax "define blocks based on the syntax file
= 3 " показать полосу для управления сворачиванием set foldcolumn = 3 "strip show for the management of folding
= 1 " Первый уровень вложенности открыт, остальные закрыты set foldlevel = 1 "The first level of nesting is open, the other closed
" правильное сворачивание классов и функций Perl let perl_folding = 1 "correct folding classes and functions Perl
" правильное сворачивание классов и функций PHP let php_folding = 1 "correct folding classes and PHP functions
=all " автоматическое открытие сверток при заходе в них set foldopen = all "automatic opening of the package upon arrival in their
"Settings Indents
= 4 " размер отступов set shiftwidth = 4 "indentation size
= 3 " ширина табуляции set tabstop = 3 "width tabs
= 3 " ширина 'мягкого' таба set softtabstop = 3 "width" soft "tabs
" ai - включить автоотступы set autoindent "ai - enable autoindent
" ci - отступы в стиле С set cindent "ci - C-style indentation
" Преобразовать табуляцию в пробелы set expandtab "Convert tabs to spaces
" Умные отступы (например, автоотступ после {) set smartindent "Smart indentation (eg, auto-indent after {)
"For these types of files off replacing tabs with spaces and change the width of the indentation
crontab,fstab,make set noexpandtab tabstop = 8 shiftwidth = 8 au FileType crontab, fstab, make set noexpandtab tabstop = 8 shiftwidth = 8
"Configuring FILE
"Encoding the default editor (when you open all the files contained in this encoding)
( 'win32' ) if has ('win32')
=cp1251 set encoding = cp1251
else
=utf - 8 set encoding = utf - 8
=utf - 8 set termencoding = utf - 8
endif
=unix,dos,mac " формат файла по умолчанию (влияет на окончания строк) - будет перебираться в указанном порядке set ffs = unix, dos, mac "default file format (affecting line endings) - will move in that order
=utf - 8 ,cp1251,koi8 - r,cp866 " варианты кодировки файла по умолчанию (все файлы по умолчанию сохраняются в этой кодировке) set fencs = utf - 8, cp1251, koi8 - r, cp866 "encoding options for the default file (all files are stored by default in this encoding)
"" Use file types
filetype on
filetype plugin on
filetype indent on
сделать его исполняемым "" If you saved the file is a script - make it executable
BufWritePost * if getline ( 1 ) = ~ "^#!.*/bin/" | silent ! chmod a + x %| endif "" Au BufWritePost * if getline (1) = ~ "^#!.*/ bin / "| silent! Chmod a + x% | endif
"" When you open the file specified for a corresponding 'compiler'
BufEnter *. pl compiler perl autocmd! BufEnter *. pl compiler perl
"Environment variable settings
( 'win32' ) if has ('win32')
VIMRUNTIME = $ HOME . ' \P rograms \V im \v im72' let $ VIMRUNTIME = $ HOME. '\ P rograms \ V im \ v im72'
mswin . vim source $ VIMRUNTIME / mswin. vim
else
VIMRUNTIME = $ HOME . '/.vim' let $ VIMRUNTIME = $ HOME. '/. vim'
endif
"Appearance Settings
для Windows и Linux ) "" Set the font (for Windows and Linux)
( 'gui' ) if has ('gui')
( 'win32' ) if has ('win32')
=Lucida_Console : h10 : cRUSSIAN :: set guifont = Lucida_Console: h10: cRUSSIAN::
else
=Terminus\ 10 set guifont = Terminus \ 10
endif
endif
"" Maximize the editor window to full screen
( 'gui' ) if has ('gui')
=T " отключить меню в GUI set guioptions - = T "off the menu in the GUI
* : set lines = 99999 columns = 99999 au GUIEnter *: set lines = 99 999 columns = 99,999
endif
"Backup Settings
" включить сохранение резервных копий set backup "enable backups
bufwritepre * call BackupDir ( ) " сделаем резервную копию перед записью буффера на диск autocmd! bufwritepre * call BackupDir () "will make a backup before writing the buffer to disk
"" Save smart backups daily
BackupDir ( ) function! BackupDir ()
"Define a directory to save the backup
( 'win32' ) if has ('win32')
backupdir = $ VIMRUNTIME . ' \b ackup' let l: backupdir = $ VIMRUNTIME. '\ b ackup'
else
backupdir = $ VIMRUNTIME . '/backup/' . let l: backupdir = $ VIMRUNTIME. '/ backup /'.
expand ( '%:p:h' ) , '^' .$ HOME, '~' , '' ) \ Substitute (expand ('%: p: h'), '^'. $ HOME, '~','')
endif
"If the directory does not exist, create it recursively
isdirectory ( l : backupdir ) if! isdirectory (l: backupdir)
( l : backupdir , 'p' , 0700 ) call mkdir (l: backupdir, 'p', 0700)
endif
"Redefine the backup directory
amp;amp; backupdir =l : backupdir let & amp; amp; backupdir = l: backupdir
"Redefine the expansion of the backup file
amp;amp; backupext = strftime ( '~%Y-%m-%d~' ) let & amp; amp; backupext = strftime ('~% Y-% m-% d ~')
endfunction
"Settings toggle keyboard layouts
"" Taken from konishchevdmitry
=russian - jcukenwin " настраиваем переключение раскладок клавиатуры по <C-^> set keymap = russian - jcukenwin "set up the switching of the keyboard on <C-^>
= 0 " раскладка по умолчанию - английская set iminsert = 0 "by default layout - English
MyKeyMapHighlight ( ) function! MyKeyMapHighlight ()
amp;amp; iminsert == 0 " при английской раскладке статусная строка текущего окна будет серого цвета if & amp; amp; iminsert == 0 "in the English keyboard layout of the current window status bar will be gray
hi StatusLine ctermfg = Gray guifg = Gray
else "and in Russian - green.
hi StatusLine ctermfg = DarkGreen guifg = DarkGreen
endif
endfunction
" при старте Vim устанавливать цвет статусной строки call MyKeyMapHighlight () "when starting Vim set the color of the status bar
* : call MyKeyMapHighlight ( ) " при смене окна обновлять информацию о раскладках au WinEnter *: call MyKeyMapHighlight () "when you change the windows update information on layouts
C - F > < C -^> " использовать Ctrl+F для переключения раскладок cmap <silent> <C - F> <C - ^> "to use Ctrl + F to switch keyboard layouts
C - F > < C -^> X < Esc >: call MyKeyMapHighlight ( ) < CR > a < C - H > imap <silent> <C - F> <C - ^> X <Esc>: call MyKeyMapHighlight () <CR> a <C - H>
C - F > a < C -^> <Esc> : call MyKeyMapHighlight ( ) <CR> nmap <silent> <C - F> a <C - ^> <Esc>: call MyKeyMapHighlight () <CR>
C - F > < Esc > a < C -^> <Esc> : call MyKeyMapHighlight ( ) < CR > gv vmap <silent> <C - F> <Esc> a <C - ^> <Esc>: call MyKeyMapHighlight () <CR> gv
"Turning AVTODOPLNENIYA INPUT (omnifunct)
python set omnifunc =pythoncomplete#Complete autocmd FileType python set omnifunc = pythoncomplete # Complete
tt2html set omnifunc =htmlcomplete#CompleteTags autocmd FileType tt2html set omnifunc = htmlcomplete # CompleteTags
javascript set omnifunc =javascriptcomplete#CompleteJS autocmd FileType javascript set omnifunc = javascriptcomplete # CompleteJS
html set omnifunc =htmlcomplete#CompleteTags autocmd FileType html set omnifunc = htmlcomplete # CompleteTags
css set omnifunc =csscomplete#CompleteCSS autocmd FileType css set omnifunc = csscomplete # CompleteCSS
xml set omnifunc =xmlcomplete#CompleteTags autocmd FileType xml set omnifunc = xmlcomplete # CompleteTags
php set omnifunc =phpcomplete#CompletePHP autocmd FileType php set omnifunc = phpcomplete # CompletePHP
c set omnifunc =ccomplete#Complete autocmd FileType c set omnifunc = ccomplete # Complete
"Hotkeys
"F2 - save the file
w < cr > nmap <F2>: w <cr>
esc >: w < cr > i vmap <F2> <esc>: w <cr> i
esc >: w < cr > i imap <F2> <esc>: w <cr> i
"F5 - View a list of buffers
buffers < cr > nmap <F5> <Esc>: buffers <cr>
esc >: buffers < cr > vmap <F5> <esc>: buffers <cr>
esc >< esc >: buffers < cr > imap <F5> <esc> <esc>: buffers <cr>
"F6 - previous buffer
: bp < cr > map <F6>: bp <cr>
esc >: bp < cr > i vmap <F6> <esc>: bp <cr> i
esc >: bp < cr > i imap <F6> <esc>: bp <cr> i
"F7 - the next buffer
: bn < cr > map <F7>: bn <cr>
esc >: bn < cr > i vmap <F7> <esc>: bn <cr> i
esc >: bn < cr > i imap <F7> <esc>: bn <cr> i
"F9 - to save the file and start the compilation (make)
: w < cr >: make < cr > map <F9>: w <cr>: make <cr>
esc >: w < cr >: make < cr > i vmap <F9> <esc>: w <cr>: make <cr> i
esc >: w < cr >: make < cr > i imap <F9> <esc>: w <cr>: make <cr> i
"F10 - enable-disable the browser document structure (TagList)
: TlistToggle < cr > map <F10>: TlistToggle <cr>
esc >: TlistToggle < cr > vmap <F10> <esc>: TlistToggle <cr>
esc >: TlistToggle < cr > imap <F10> <esc>: TlistToggle <cr>
"F11 - turn on / off line numbering
set < Space > nu !< CR > a imap <F11> <Esc>: set <Space> nu! <CR> a
set < Space > nu ! <CR> nmap <F11>: set <Space> nu! <CR>
"F12 - File Browser (: Ex a standard browser plug-NERDTree -
"The directory tree)
: NERDTreeToggle < cr > map <F12>: NERDTreeToggle <cr>
esc >: NERDTreeToggle < cr > i vmap <F12> <esc>: NERDTreeToggle <cr> i
esc >: NERDTreeToggle < cr > i imap <F12> <esc>: NERDTreeToggle <cr> i
вкладок ) "" Switching tabs (tabs)
S - tab > : tabprevious < cr > map <S - tab>: tabprevious <cr>
tab > : tabprevious < cr > nmap <S - tab>: tabprevious <cr>
tab > < ESC >: tabprevious < cr > i imap <S - tab> <ESC>: tabprevious <cr> i
C - tab > : tabnext < cr > map <C - tab>: tabnext <cr>
tab > : tabnext < cr > nmap <C - tab>: tabnext <cr>
tab > < ESC >: tabnext < cr > i imap <C - tab> <ESC>: tabnext <cr> i
t > : tabnew < cr > nmap <C - t>: tabnew <cr>
t > < ESC >: tabnew < cr > imap <C - t> <ESC>: tabnew <cr>
w > : tabclose < cr > nmap <C - w>: tabclose <cr>
w > < ESC >: tabclose < cr > imap <C - w> <ESC>: tabclose <cr>
"" Changing the Encoding file
set wildmenu
= < Tab > set wcm = <Tab>
e ++ enc =cp1251 < CR > menu Encoding. CP1251: e + + enc = cp1251 <CR>
e ++ enc =cp866 < CR > menu Encoding. CP866: e + + enc = cp866 <CR>
U : e ++ enc =koi8 - u < CR > menu Encoding. KOI8 - U: e + + enc = koi8 - u <CR>
8 : e ++ enc =utf - 8 < CR > menu Encoding. UTF - 8: e + + enc = utf - 8 <CR>
: emenu Encoding .< TAB > map <F8>: emenu Encoding. <TAB>
"C (trl) + d - duplication of the current line
d > < esc > yypi imap <C - d> <esc> yypi
"Ctrl-Space for autocomplete
space > < C - x >< C - o > inoremap <C - space> <C - x> <C - o>
"Ce - comment / uncomment (by NERD_Comment)
C - e > , ci map <C - e>, ci
e > , ci nmap <C - e>, ci
e > < ESC > ,cii imap <C - e> <ESC>, cii
копировать - вставить через Ctrl "" Cut - Copy - Paste via Ctrl
X > "+x " CTRL - X - вырезать vnoremap <C - X> "+ x" CTRL - X - cut
C > "+y " CTRL - C - копировать vnoremap <C - C> "+ y" CTRL - C - copy
C - V > "+gP " CTRL - V вставить под курсором map <C - V> "+ gP" CTRL - V to insert under the cursor
вернуть через Ctrl "" Cancel - to return via Ctrl
C - Z > u " отмена действия noremap <C - Z> u "abolition of the
Z > < C - O > u inoremap <C - Z> <C - O> u
C - Y > < C - R > " вернуть отменённое назад noremap <C - Y> <C - R> "redo ago
Y > < C - O >< C - R > inoremap <C - Y> <C - O> <C - R>
I hope that someone so useful!
More on similar topics:
Filed under: Linux , Gadgets , Coding |
Tags: . rc , How-to , linux , vim |
2 comments 

Instead of:
027. "" Jump to the last place at the opening of the buffer
028.autocmd! bufreadpost * call LastPosition ()
029. function! LastPosition ()
030. if line ("'\" ") & & line ("' \ "")<= line ('$')
031. normal! `"
032. endif
033. endfunction
much wiser to do:
au BufWinLeave *.* silent mkview
au BufWinEnter *.* silent loadview
In the latter case, the state of folding is preserved.
Checked for gvim 7.2 for windows - does not work, when opening the file pointer is always on the first character of the first row. loadview hour not to swap Wim tied? I have it disabled.
Try it at home linuh.