Created
February 6, 2011 05:25
-
-
Save mitry/813151 to your computer and use it in GitHub Desktop.
~mitry/.vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" (#) ~/.vimrc | |
" Description: vim имеет всего два режима - бибикать и все портить. :-) | |
" Author: dMitry Alexandrov <mitry (at) mitry.spb.ru> | |
" Created: 2003-08-24 | |
" Version: $Id: .vimrc,v 27b476a4c6f4 2012/10/21 06:59:09 mitry $ | |
version 6.2 | |
scriptencoding utf-8 | |
""" Options: {{{1 | |
""" ====================================== | |
""" General: {{{2 | |
set nocompatible " It is important to set this first | |
set exrc " enable reading .vimrc/.exrc/.gvimrc in the current directory | |
set cpoptions=BceFsM " list of flags to specify Vi compatibility | |
"set nopaste " paste mode, insert typed text literally | |
"set pastetoggle=<F13> " key sequence to toggle paste mode | |
"set helpfile " name of the main help file | |
"set runtimepath " list of directories used for runtime files and plugins | |
if has('win32') | |
set runtimepath=~/.vim,$VIMRUNTIME,~/.vim/after | |
endif | |
" use pathogen <https://github.com/tpope/vim-pathogen> for runtimepath | |
" call pathogen#infect() | |
""" Store an editing session in the viminfo file; can be used at next session. | |
" set sessionoptions=buffers,folds,sesdir,slash,unix | |
set sessionoptions=folds,curdir,slash,unix,tabpages | |
set viminfo='50,<10,f1,s1,%,!,n~/.vim/.viminfo | |
set viewoptions=folds,options,cursor,unix,slash " better unix/windows compatibility | |
set viewdir=~/.vim/view " directory where to store files with :mkview (~/.vim/view) | |
set directory=~/.backup// " directories for the swap file (last // - use full file path) | |
"set noloadplugins " don't load plugin scripts when starting up | |
set debug=msg " set to `msg` to see error messages for 'foldexpr' & 'indentexpr' | |
"set verbose=9 " the higher the more messages are given | |
"set insertmode " Insert mode is the default mode - makes Vim a modeless editor. | |
"set eventignore= " list of autocommand events which are to be ignored | |
set isfname-== isf-=[ isf-=] isf-=# " specifies the characters in a file name | |
if exists('&cryptmethod') " new v7.3 encryption | |
set cryptmethod=blowfish | |
endif | |
""" GUI: {{{2 | |
"set lm=ru_RU.cp1251 " langmenu: language to be used for the menu | |
set winaltkeys=no " Don't use ALT keys for menus. | |
set guioptions=gmMre " list of flags that specify how the GUI works | |
" T = Toolbar | |
" M = '$VIMRUNTIME/menu.vim' isn't sourced. | |
" m = Show menu | |
" t = tear-off menus | |
" L = Left-hand scrollbar isn't present | |
" e = tab pages when &showtabline > 0 | |
if has("gui_win32") | |
" VimTip414: межстрочный интервал в gvim можно уменьшать: | |
set guifont=Consolas:h11:cRUSSIAN lsp=-1 lines=999 columns=100 | |
endif | |
""" Windows: {{{2 | |
set noequalalways " don't make all windows the same size when adding/removing windows | |
" set nowinfixheight " don't keep the height of the window | |
" set eadirection=ver " in which direction 'equalalways' works: 'ver', 'hor' or 'both' | |
set hidden " don't unload a buffer when no longer shown in a window | |
set switchbuf=useopen,split,usetab " which window to use when jumping | |
set splitbelow " a new window is put below the current one (with :split and :help) | |
set splitright " a new window is put right of the current one (with :vsplit) | |
set winwidth=20 " minimal number of columns used for the current window | |
" set lines=999 " number of lines in the VIM display | |
" set winminwidth=3 " minimal number of columns used for any window | |
" set winheight=20 " minimal number of lines used for the current window | |
set helpheight=10 " initial height for a help window | |
set previewheight=7 " initial height for a preview window | |
set winheight=999 " current window fill most of the screen, | |
" other windows will be only 'winminheight' high. | |
""" statusline: | |
" let &stl='--<%02n> %1*%t%* %3*%M%*[%(%R%W%Y%),%{&fenc}:%{&ff}] %2*%{mode()}%* %4*%k%* %= 0x%B @ %4*%l%*/%L:%c%V --' | |
set statusline=--<%02n>\ %1*%t%*\ %4*%M%*[%(%R%W%Y%),%{&fenc}:%{&ff}]\ %4*%{mode()}%*\ %4*%k%*\ %=\ 0x%B\ @\ %2*%l%*/%L:%c%V\ -- | |
set laststatus=2 " Always a status line | |
""" Moving Around Searching And Patterns: {{{2 | |
"set path=,;~/GTD/** " list of directory names used for file searching | |
set path=.,,~/GTD/** " -- "" -- | |
set cdpath=,,.,~ " list of directory names used for :cd | |
set nogdefault " (don't) Use `g` flag by default in substitutes | |
set nohlsearch " (no)highlighting the last used search pattern | |
set incsearch " show match for partly typed search command | |
set ignorecase " ignore case when using a search pattern | |
set magic " 'magic' patterns - extended regular expressions: \s+ | |
set smartcase " override 'ignorecase' when pattern has upper case characters | |
set nostartofline " Don't jump to start of line after delete and other misc commands | |
set whichwrap=<,>,[,],h,l,b,s,~ " list of flags specifying which commands wrap to another line | |
set whichwrap=<,>,[,],b " list of flags specifying which commands wrap to another line | |
set wrapscan " Searches wrap around the end of the file. | |
set virtualedit=block " Cursor can be anywhere in Visual block mode | |
"set virtualedit=all " Cursor can be anywhere in all modes | |
""" Tags: {{{2 | |
set tags+=./tags;/ " list of file names to search for tags: Upward tag search | |
set showfulltag " when completing tags in Insert mode show more info | |
"set tagbsearch " use binary searching in tags files | |
"set taglength=0 " number of significant characters in a tag name or zero | |
"set tagrelative " file names in a tags file are relative to the tags file | |
"set tagstack " a :tag command will use the tagstack | |
""" Displaying Text: {{{2 | |
set display=lastline " show the last line even if it doesn't fit - no @ | |
set lazyredraw " don't redraw while executing macros | |
set nonumber " don't show the line number for each line | |
set scrolloff=3 " number of screen lines to show around the cursor | |
set sidescroll=1 " minimal number of columns to scroll horizontally | |
set sidescrolloff=3 " minimal number of columns to keep left and right of the cursor | |
set linebreak " wrap long lines at a character in 'breakat' | |
set fillchars=stl:-,stlnc:-,vert:\|,fold:\ ,diff:- | |
set showbreak=>> | |
set nolist " Don't show <Tab> as ^I and end-of-line as $ | |
set nowrap " no long lines wrap | |
if has('gui_running') || (&termencoding == "utf-8") | |
" list of strings used for list mode | |
set listchars=tab:\|»,trail:·,eol:¶,extends:…,precedes:…,nbsp:¬ | |
set fillchars=stl:,stlnc:,vert:\|,fold:·,diff:× | |
" let &listchars='tab:|'.nr2char(0xBB).',trail:'.nr2char(0xB7).',eol:'.nr2char(0xB6).',extends:'.nr2char(0x2026).',precedes:'.nr2char(0x2026).',nbsp:'.nr2char(0xAC) | |
" let &fillchars='stl:'.nr2char(0xAD).',stlnc:'.nr2char(0xAD).',vert:|,fold:'.nr2char(0xB7).',diff:'.nr2char(0xBF) | |
endif " has('gui_running') | |
""" Terminal: {{{2 | |
set ttyfast " terminal connection is fast | |
"set term=builtin_gui " name of the used terminal | |
"set guicursor " specifies what the cursor looks like in different modes | |
"set titlelen=85 " percentage of 'columns' used for the window title | |
set titlestring=%F\ %h%w\ -\ gViM " string to be used for the window title | |
set title " show info in the window title | |
set icon " set the text of the icon for this window | |
"set iconstring " when not empty, text for the icon of this window | |
"set norestorescreen " restore the screen contents when exiting Vim | |
set esckeys " recognize keys that start with <Esc> in Insert mode | |
""" Mouse: {{{2 | |
set mousehide " Hide the mouse pointer while typing | |
set mousemodel=extend " what the right mouse button is used for | |
set nomousefocus " the window with the mouse pointer becomes the current one | |
""" Messages And Info: {{{2 | |
set confirm " Always use ':confirm' | |
set shortmess=aOItT " To avoid the 'Hit ENTER to continue' prompt | |
set showcmd " Show current uncompleted command | |
set showmode " (no)show the current mode | |
set report=0 " Report when N lines were changed. report=0 : show all changes | |
set noruler " (no)Show the cursor position all the time | |
set noerrorbells " no Ring the bell (beep or screen flash) for error messages. | |
set novisualbell " (don't) Use visual flashing instead of beeping. | |
"set verbose=0 " show messages about what VIM is doing. | |
""" Selecting: {{{2 | |
set selection=exclusive " Selection is exclusive, mswin-style | |
"set selection=inclusive " Selection is inclusive, unix-style | |
"set selection=old " / behave mswin | |
set keymodel=startsel,stopsel " Use shifted cursor keys to start/stop selection | |
set selectmode= " No Select-mode: no replace selection with typing | |
""" Editing: {{{2 | |
set backspace=2 " BackSpacing over everything (indent,eol,start) in insert mode | |
set undolevels=100 " maximum number of changes that can be undone | |
set tildeop " `~` command behaves like an operator | |
if has("unix") " list of dictionary files for keyword completion | |
set dictionary=~/.words,/usr/share/dict/*.words | |
else | |
set dictionary=~/.words,c:/usr/share/dict/*.words | |
endif | |
"set thesaurus= " list of thesaurus files for keyword completion | |
set complete=.,w,b,t,k,i " specifies how Insert mode completion works | |
if has('spell') | |
set complete+=kspell | |
endif | |
set formatoptions=crqon1 " list of flags that tell how automatic formatting works | |
" t = Auto-wrap text using textwidth (does not apply to comments) | |
" c = Auto-wrap comments, inserting the comment leader | |
" r = Insert the comment leader after hitting <Enter> in Insert mode. | |
" o = Insert the comment leader after hitting 'o' or 'O' in Normal mode. | |
" q = Allow formatting of comments with "gq". | |
" n = Auto-listing | |
" 1 = Don't break a line after a one-letter word. | |
set infercase " adjust case of a keyword completion match | |
set showmatch " show the matching bracket for the last ')' | |
set matchtime=3 " tenth of a second to show a match for 'showmatch' (def=5) | |
set nrformats=alpha,hex " number formats recognized for CTRL-A and CTRL-X commands | |
if v:version >= 700 | |
set completeopt=longest,menu,preview | |
endif | |
""" Tabs And Indenting: {{{2 | |
set autoindent " always set autoindenting on | |
set smartindent " do clever autoindenting | |
set cinkeys+=; " figure out indent when ; is pressed | |
set noexpandtab " no expand <Tab> to spaces in Insert mode | |
set shiftround " round to 'shiftwidth' for `<<` and `>>` | |
set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces | |
set tabstop=8 " Number of spaces that a <Tab> in the file counts for. | |
"set copyindent " Copy whitespace for indenting from previous line | |
"set preserveindent " Preserve kind of whitespace when changing indent | |
set cinoptions=:0,l1,t0,g0,(0 " C-Indent options: Linux-kernel style | |
""" Folding: {{{2 | |
set foldenable " set to display all folds open | |
set foldlevel=0 " Min folding level | |
set foldlevelstart=-1 " value for 'foldlevel' when starting to edit a file | |
set foldclose=all " close a fold when the cursor leaves it | |
"set foldopen=all " specifies for which commands a fold will be opened | |
set foldminlines=1 " minimum number of screen lines for a fold to be closed | |
set foldmethod=marker " folding type: 'manual', 'indent', 'expr', 'marker' or 'syntax' | |
if has('gui') " && winwidth(0) > 80 | |
set foldcolumn=3 " width of the column used to indicate folds | |
endif | |
""" DiffMode: {{{2 | |
set diffopt=filler,context:4,iwhite " options for using diff mode | |
"set diffexpr " expression used to obtain a diff file | |
"set patchexpr " expression used to patch a file | |
""" Reading And Writing: {{{2 | |
set noautoread " (don't) automatically read a file when it was modified outside of Vim | |
set backup " keep a backup file | |
"set patchmode=.orig " keep oldest version of a file with this extension | |
set backupskip+=.passwd " patterns which files a backup is not made | |
set backupdir=~/.backup,~/tmp,/tmp,c:/tmp | |
set fileformat=unix " end-of-line format: unix - not dos | |
set fileformats=unix,dos " list of file formats to look for when editing a file | |
set modeline " enable using settings from modelines when reading a file (vim:ts=8:fenc=koi8-r) | |
set modelines=3 " number of lines to scan for modeline | |
""" CommandLine Editing: {{{2 | |
set history=50 " keep 50 lines of command line history | |
set wildmode=longest:full,full " specifies how command line completion works | |
set wildmenu " enhanced mode command-line completion | |
set wildcharm=<Tab> " wildcard expansion inside a macro | |
""" Ignore at auto-completion: | |
set wildignore=*.o,*.obj,*.exe,*.dll,*.com,*.class,*.au,*.wav,*.mp[23g],*.jar,*.rar,*.zip,*.gz,*.tgz,*.avi,*.wmv,*.flv,*.djvu,*.pdf,*.chm,*.ps,*.dvi,tags,descript.ion,desktop.ini,*/CVS/,*/.hg/,manifest.uuid,_FOSSIL_,*.~*,*~ | |
""" Name extensions with lower priority | |
set suffixes+=.log | |
set suffixes+=.out | |
set suffixes+=.COPYING | |
""" External Commands: {{{2 | |
set shellslash " use forward slashes in file names; for Unix-like shells | |
if v:version < 700 | |
set grepprg=grep\ -rnEH " program to use for the `:grep` command | |
else | |
set grepprg=internal | |
endif | |
if has("filterpipe") | |
set noshelltemp " Use pipes on Unix | |
endif | |
set formatprg= " program used to format lines with 'gq' command | |
set equalprg= " program used for '=' command (global or local to buffer) | |
set keywordprg= " program used for the 'K' command | |
" set warn " warn when using a shell command and a buffer has changes | |
""" MultiByte Chars: {{{2 | |
set encoding=utf-8 | |
set fileencodings=ucs-bom,utf-8,cp1251,koi8-r,cp866,java | |
set keymap=russian-jcukenwin | |
set iminsert=0 " latin input as default | |
set imsearch=0 " latin search as default | |
" so <sfile>:p:h/keymap/russian-jcuken-win.vim | |
if has('win32') && !has("gui_running") && $SHELL != '' | |
set termencoding=8bit-cp1252 | |
endif | |
if has('win32') | |
language ctype Russian_Russia.1251 | |
endif | |
""" Spelling: {{{2 | |
if has("spell") | |
set spelllang=en,ru | |
set spellfile=~/.words.utf-8.add | |
map <Leader><F3> :setlocal spell! spell?<CR> | |
endif | |
" ====================================== }}}1 | |
""" Environment: {{{1 | |
let $EDITOR = (has('gui_running')?'g':'') . 'vim --remote-tab-silent' | |
let $TERM = has('gui_running')? 'dumb' : $TERM | |
""" Colors And Position: {{{1 | |
""" Color scheme must be loaded _before_ `syntax on` | |
if has('gui_running') | |
colorscheme tango-mitry | |
else | |
colorscheme Norton | |
endif | |
if has("gui_win32") | |
let g:browsefilter = | |
\ "All Files (*.*)\t*.*\n" | |
\."Config Files (*.ini *.cfg *.rc)\t*.ini;*.cfg;*.rc\n" | |
\."C/C++ Source Files (*.c *.cpp *.h *.hpp)\t*.c;*.cpp;*.c++;*.h;*hpp\n" | |
\."Java Source Files (*.java *.properties)\t*.java;*.properties\n" | |
\."Batch Files (*.bat *.cmd)\t*.bat;*.cmd\n" | |
\."Perl Scripts (*.pl *.pm)\t*.pl;*.pm\n" | |
\."HTML Files (*.htm *.html *.jsp *.css)\t*.htm;*.html;*.jsp;*.css\n" | |
\."Vim scripts (*.vim .vimrc)\t*.vim;.vimrc;.gvimrc;_vimrc;_gvimrc;\n" | |
endif | |
""" AutoCommands: {{{1 | |
filetype plugin indent on " Enable file type detection | |
syntax on | |
function! s:HiddenExec(str) " Execute str keeping jumps and regisers {{{2 | |
if &ma && ! &ro | |
normal! m` | |
silent exe a:str | |
normal! g``zv | |
call histdel("/", -1) | |
let @/ = histget("/", -1) | |
endif | |
endfunction " }}}2 | |
augroup ENCODINGS " {{{2 | |
au! | |
""" To show lang name on the statusline | |
au BufNewFile,BufRead * let b:keymap_name="RU" | |
au FileType jproperties nested Encoding java | |
au FileType mail nested Encoding koi8-r | |
" au FileType dosini nested Encoding cp1251 | |
augroup END | |
augroup AUTOMOD " {{{2 | |
au! | |
""" Save the buffer marks | |
au BufUnload * wviminfo! | |
""" Remove trailing blanks and ^M | |
au BufRead * call s:HiddenExec('%s/\r\+$//e') | |
au BufWritePre,FileWritePre * call s:HiddenExec('%s/\s\+$//e') | |
""" To insert the current date and time in a *.html file when writing it: | |
au BufWritePre *.htm,*.html,*.php call s:HiddenExec('%s/\<last modified:\zs\s*\S*/\=strftime(" %Y-%m-%d")/ie') | |
augroup END | |
augroup VIMrc " // FileType Additions: {{{2 | |
au! | |
""" Use visual flashing instead of beeping & disable visualbells | |
au GUIEnter * set vb t_vb= | |
au GUIEnter * winpos 0 0 | |
""" Show today diary file | |
" au VimEnter * let diary_file = expand(substitute(strftime('~/diary/%Y/%m/%d.cal'),'/0','/','g')) | |
" au VimEnter * if filereadable(diary_file) | exe "pedit" diary_file | endif | |
au FileType log,httplog setlocal autoread nomodifiable ro noswapfile fdc=0 | |
au FileType log,httplog nnoremap <buffer>r :view!<CR> | |
"previewwindow | |
""" To use use a syntax file as a dictionary. | |
" au Syntax * exec('set dict+='.$VINRUNTIME.'/'. expand('<amatch>') .'.vim') | |
" au FuncUndefined * silent! source ~/.vim/macros/<afile>.vim | |
""" Jump to the last place you had been while reading Vim help files by use 'H | |
au BufLeave * if &bt=='help' | mark H | endif | |
" Move help or preview window up | |
au BufWinEnter * if &ft=~'^\v(help|man|info)$' || &pvw | exe 'wincmd K' | endif | |
""" VimTip214: Current buffer based menus. | |
""" If you have different menus for different filetypes, and you want to have | |
""" only the menu relevant to current buffer displayed, you can use this approach: | |
au BufEnter * exe exists('b:BuffEnter')? b:BuffEnter : '' | |
au BufLeave * exe exists('b:BuffLeave')? b:BuffLeave : '' | |
au BufNewFile,BufRead *.m3u,*.pls :nno <lt>buffer>gx :!start mplayer -nocache <C-R><C-F><CR> | |
if has('windows') | |
au BufNewFile,BufRead ~/.passwd :silent! wincmd T|tabmove 0 | |
endif | |
au CursorHold ~/.passwd :setl ro|norm! zX | |
augroup END | |
augroup SyntaxAdd " {{{2 | |
au! | |
au Syntax * syn match WhitespaceEOL containedin=TOP /\s\+$/ | |
au Syntax * syn match WhitespaceEOL containedin=TOP / \+\t/he=e-1 | |
au Syntax * syn match WhitespaceEOL containedin=TOP /\t \+/hs=s+1 | |
au Syntax help,todo,man,markdown syn clear WhitespaceEOL | |
au Syntax *.[ch],*.[ch]pp runtime syntax/doxygen.vim | |
augroup END | |
augroup SESSSIONS " {{{2 | |
au! | |
au BufWinLeave *.* silent! mkview! | |
au BufReadPost *.* silent! loadview | |
au VimLeavePre * mksession! ~/.vim/Session.vim | |
augroup END | |
augroup CMDWindow " // Command Window: {{{2 | |
au! | |
""" Save new history after editing | |
au CmdwinEnter * map <buffer><ESC> :q<CR> | |
au CmdwinLeave * exe 'call histdel("'.expand('<afile>').'")|%call histadd("'.expand('<afile>').'",getline("."))' | |
augroup END | |
augroup CVSCommand "{{{2 | |
au User CVSBufferSetup map <buffer>q :bwipeout<CR> | |
au User CVSBufferSetup map <buffer><ESC> :bwipeout<CR> | |
augroup END | |
augroup GnuPG " {{{2 | |
au! | |
au BufReadPost *.asc :%!gpg -qd | |
au BufWritePre *.asc :%!gpg -qea | |
au BufWritePost *.asc :undo | |
if !has("gui_running") | |
au BufReadPost *.asc :redraw! | |
endif | |
augroup END | |
augroup EXTEXE " // Associations: {{{2 | |
au! | |
if has('win32') | |
""" Execute command and close opened for it buffer | |
command! -nargs=* -bang -complete=file SExe silent<bang> exe '!start' iconv(<q-args>,&enc,'cp1251') |bu#|bw!# | |
""" To make gf worked for URL, say, file:///C:/myfile.txt | |
au BufReadCmd file://* bd!|edit <afile>:p:s?^file://?? | |
au BufReadCmd reg://* SExe! NirCmd.exe regedit <afile>:p:s?^reg://?? | |
au BufReadCmd http://* SExe! NirCmd.exe shexec open <afile>:p | |
""" Multimedia (don't work w/out exe '!start' ; no spaces in path) | |
""" au BufReadCmd *.mp3 SExe! madplay --tty-control <afile>:p | |
au BufReadCmd *.exe SExe! <afile>:p | |
au BufReadCmd *.lnk,*.url,*.chm,*.pdf,*.djvu,*.zip,*.rar,*.mp3 | |
\ SExe! NirCmd.exe shexec open "<afile>:p" | |
au BufReadCmd *.jpg,*.gif,*.ico,*.png,*.bmp,*.icl | |
\ SExe! NirCmd.exe shexec view "<afile>:p" | |
endif | |
""" Decompile java classes | |
au BufReadCmd *.class exe '0r!jad -p <afile>' | |
au BufReadCmd *.class exe setlocal ft=java bt=nowrite nomod noma | |
augroup END | |
" ====================================== }}}1 | |
""" Syntax Highlighting: {{{1 | |
""" Should be set _after_ 'syntax on' | |
hi! link StorageClass Statement | |
hi! link Structure Statement | |
hi! link Function Normal | |
""" Highlighting whitespaces at end of line | |
hi! link WhitespaceEOL WarningMsg | |
hi! link diffRemoved Comment | |
hi! link diffAdded PreProc | |
let readline_has_bash = 1 | |
let is_bash = 1 | |
let sh_fold_enabled= 1 | |
""" Environment: {{{1 | |
let $EDITOR = (has('gui_running')?'g':'') . 'vim --remote-tab-silent' | |
let $TERM = has('gui_running')? 'dumb' : $TERM | |
""" Plugins: {{{1 | |
let user = 'dMitry Alexandrov' " used by Templates | |
let replyto = strlen($REPLYTO)? $REPLYTO : "[email protected]" " - '' - | |
let copyright = 'Mitrysoft Corp., ' . strftime("%Y") | |
let username = $USERNAME " used by JCommenter | |
let spec_chglog_format = '%Y-%n-%d ' .user.' <'.replyto.'>' | |
""" Explore: {{{2 | |
let explDetailedHelp=0 " Show more help | |
let explDetailedList=0 " the size and date to do not show by default | |
let explVertical=1 " Split vertically | |
let explWinSize=25 " the number of rows or columns | |
let explDirsFirst=-1 " Directories at the bottom of the list | |
let explSplitRight=1 " Put new window to the right of the explorer | |
let explStartRight=0 " Put new explorer window to the left of the current window | |
let explUseSeparators=0 " Include separator lines between directories, files, and suffixes | |
"let explHideFiles='^\.,\.gz$,\.exe$,\.dat$,\.zip$,\.class$,\.log$' | |
noremap <silent><F11> :aboveleft 25vsplit %:p:h<CR> | |
map <silent>gz <Plug>NetrwBrowseX | |
""" TagList: {{{2 | |
let Tlist_Inc_Winwidth=1 | |
let Tlist_Display_Prototype=0 | |
let Tlist_Compact_Format=1 | |
let Tlist_Exit_OnlyWindow=1 | |
map <silent><M-F11> :Tlist<CR> | |
""" Calendar: {{{2 | |
let g:calendar_navi_label = 'Пред,Сегодня,След' | |
let g:calendar_mruler = 'Янв,Фев,Мар,Апр,Май,Июн,Июл,Авг,Сен,Окт,Ноя,Дек' | |
let g:calendar_wruler = 'Вс Пн Вт Ср Чт Пт Сб' | |
let g:calendar_monday = 1 | |
let g:calendar_focus_today=1 | |
hi! CalWeekend guifg=red | |
hi! link CalSaturday CalWeekend | |
hi! link CalSunday CalWeekend | |
hi! link CalMemo Type | |
hi! link CalToday Todo | |
""" map this way to disable mapping in Calendar.vim plugin (NO noremap) | |
map <C-F11> <Plug>CalendarV | |
map <C-S-F11> <Plug>CalendarH | |
""" CVSCommand: {{{2 | |
let VCSCommandDeleteOnHide=1 " automatically delete temporary CVS results | |
let VCSCommandDiffOpt='wbBu' " options passed to the diff command (fefault: wbBc) | |
let VCSCommandEdit='split' " the original buffer is replaced ('edit') or split | |
let VCSCommandEnableBufferSetup=0 " set 'CVSRevision' 'CVSBranch' vars | |
let VCSCommandMapPrefix = "<Leader>v" | |
""" MRU: {{{2 | |
let MRU_File = expand('~/.vim/.mru_files') | |
" let MRU_Max_Entries=20 | |
" let MRU_Add_Menu = 1 | |
""" Changelog: {{{2 | |
let changelog_username = username " used by changelog ftplugin | |
""" <Leader>o - switches to the ChangeLog buffer opened for the current directory. | |
runt ftplugin/changelog.vim | |
""" Commenting: {{{2 | |
""" NERD_commenter: {{{3 | |
" let loaded_nerd_comments = 1 " TODO: NERD_commenter disabled | |
" let NERDCreateDefaultMappings = 0 " no default mappings | |
" let NERDSpaceDelims = 1 " put space after comment delimiter | |
" map <silent><M-`> <plug>NERDCommenterInvert | |
""" Eclipse style commenting (<C-/>). | |
" map <silent><C-\> <plug>NERDCommenterInvert | |
" imap <C-\> <C-O><plug>NERDCommenterInvert | |
""" Copy current line and commentify it | |
" nmap <silent><C-Z><C-Z> :copy -1<CR><plug>NERDCommenterComment<ESC>j | |
" imap <C-Z><C-Z> <C-O><C-Z><C-Z> | |
""" TComment: {{{3 | |
" let loaded_tcomment = 1 " Disable TComment loading | |
map <silent><M-`> :TComment<CR> | |
" Eclipse style commenting (<C-/>). | |
map <silent><C-\> :TComment<CR> | |
imap <C-\> <C-O><C-\> | |
""" Copy current line and commentify it | |
nmap <silent><C-Z><C-Z> :copy -1<BAR>TComment<CR>j | |
imap <C-Z><C-Z> <C-O><C-Z><C-Z> | |
""" Doxygen: {{{3 | |
let DoxygenToolkit_briefTag=".." | |
let DoxygenToolkit_authorName=username | |
""" Disable Some Plugins: {{{2 | |
let loaded_matchparen=1 " showing matching parens ??? by Bram Moolenaar | |
let loaded_gzip=1 " plugin for editing compressed files | |
let loaded_GetLatestVimScripts=1 " disable GetLatestVimScripts | |
let loaded_rrhelper = 1 " helper function(s) for --remote-wait | |
" let loaded_netrw = 1 " file transfer and local/remote directory listing (Explore) | |
if has('win32') | |
let netrw_use_nt_rcp=1 " use the rcp of WinNT for netrw | |
endif | |
" let loaded_netrwFileHandlers=1 | |
" let loaded_netrwSettings=1 | |
" let loaded_vimball=1 " construct a file containing both paths and files ??? | |
let pandoc_no_empty_implicits=1 " Disable python call | |
""" ZenCoding {{{2 | |
let g:user_zen_leader_key = '<buffer><c-z>' | |
let g:use_zen_complete_tag = 1 | |
" ====================================== }}}1 | |
""" Key Mapping: {{{1 | |
""" See also: | |
""" ~/.vim/plugins/SpKeys.vim Standard mapping for <C-Fx> and <M-Fx> : | |
""" ~/.vim/plugins/MetaMove.vim blockwise select mode | |
""" Select Current Word: {{{2 | |
nmap <C-Space> ciw | |
nmap <S-Space> ciW | |
omap <C-Space> iw | |
omap <S-Space> iW | |
vmap <C-Space> iw | |
vmap <S-Space> iW | |
""" Undo: <M-BS> {{{2 | |
map <M-BS> <Undo> | |
map <M-S-BS> <C-R> | |
""" Help: <F1> {{{2 | |
if has("win32") | |
noremap <M-F1> :emenu Help.English-Russian<CR> | |
endif | |
""" Translate with Google translate (with `wget -qO -` or `curl -so -`) | |
map <silent><Leader><F1> :echo system('wget -qO - "http://translate.google.com/translate_a/t?client=vim&sl=en&tl=ru&text='.expand('<cword>').'"')<cr> | |
vmap <silent><Leader><F1> y:echo system('wget -qO - "http://translate.google.com/translate_a/t?client=vim&sl=en&tl=ru&text='.substitute(@@,'\_s\+','+','g').'"')<cr> | |
map <silent><Leader><C-F1> :echo system('wget -qO - "http://translate.google.com/translate_a/t?client=vim&sl=ru&tl=en&text='.expand('<cword>').'"')<cr> | |
vmap <silent><Leader><C-F1> y:echo system('wget -qO - "http://translate.google.com/translate_a/t?client=vim&sl=ru&tl=en&text='.substitute(@@,'\_s\+','+','g').'"')<cr> | |
""" In insert and command mode: | |
map! <F1> <C-C><F1> | |
""" How prev help topic | |
map <silent><S-F1> <C-W>s`H:setl bt=help<CR> | |
""" Show Syntax Highlighting groups the item under the cursor | |
map <silent><Leader><Leader>? :echomsg "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<cr> | |
""" Show buffer key mappings | |
map <Leader><Leader><F1> :map <LT>buffer><CR> | |
""" Deleting: {{{2 | |
noremap <C-BS> db | |
cnoremap <C-BS> <C-W> | |
""" Delete current line | |
" imap <C-Y> <C-O>dd | |
nmap <M-Del> diw | |
""" Delete to the clipboard | |
imap <S-Del> <ESC>"*yyddi | |
nmap <S-Del> "*dd | |
""" Delete the word right | |
map <C-Del> dw | |
""" Delete the rest of the line | |
map <C-S-Del> d$ | |
""" Delete empty lines in the selection | |
vmap <silent><Leader>d :g/^$/d<CR> | |
""" Don't delete whole line if selection exists | |
vmap C c | |
""" Saving: <F2> {{{2 | |
noremap <silent><F2> :update<CR> | |
noremap <silent><M-F2> :wall<CR> | |
noremap <silent><S-F2> :browse confirm saveas<CR> | |
""" Searching: <F7> {{{2 | |
" Default searches to "very magic", more like the world outside Vim. | |
" nnoremap / /\v | |
" vnoremap / /\v | |
" nnoremap ? ?\v | |
" vnoremap ? ?\v | |
nnoremap <F7> /<C-R><C-W> | |
cnoremap <F7> %s!!!g<Left><Left><Left> | |
nnoremap <C-F7> :.,$s!\<<C-R><C-W>\>!!g<Left><Left> | |
vnoremap <C-F7> y<C-\><C-N>:<C-U>.,$s!<C-R>=escape(@",'\!')<CR>!!g<Left><Left> | |
cnoremap <C-F7> .,$s!!!g<Left><Left><Left> | |
nnoremap <M-F7> :%s!\<<C-R><C-W>\>!!g<Left><Left> | |
cnoremap <M-F7> %s!!!g<Left><Left><Left> | |
""" Search current word in the other window | |
noremap <S-F7> yiw<C-W>pgg:call search(@@)<CR> | |
""" Windows: {{{2 | |
map <C-W><C-W> <C-W>p | |
map <C-W><C-P> <C-W>P | |
map <M-kPlus> <C-W>5+ | |
map <M-S-kPlus> <C-W>_ | |
map <M-kMinus> <C-W>5- | |
map <M-S-kMinus> <C-W>1_ | |
map <M-kDivide> <C-W>= | |
map <C-W><S-Up> <C-W>K | |
map <C-W><S-Down> <C-W>J | |
map <C-W><S-Left> <C-W>H | |
map <C-W><S-Right> <C-W>L | |
""" Sroll other window | |
nmap <M-C-Up> <C-W>p<C-\><C-N><C-Y><C-W>p | |
nmap <M-C-Down> <C-W>p<C-\><C-N><C-E><C-W>p | |
""" Switch buffers | |
nmap <Leader><Tab> :buffer<SPACE><TAB> | |
""" Set window height to the length of its contents (or maximize it). | |
nmap <expr><C-W><C-M> (line("$")+1)."\<C-W>_" | |
""" WinTabs support | |
if has('windows') | |
map <C-Tab> gt | |
map <C-S-Tab> gT | |
map <M-1> 1gt | |
map <M-2> 2gt | |
map <M-3> 3gt | |
map <M-4> 4gt | |
map <M-5> 5gt | |
map <M-6> 6gt | |
map <M-7> 7gt | |
map <M-8> 8gt | |
map <M-9> 9gt | |
map <M-0> 10gt | |
""" Move the current window to a new tab page. | |
" nnoremap <M-t> <C-W>T | |
else | |
map <C-Tab> :sbuffer<Space><Tab><Tab> | |
map <C-S-Tab> <C-^> | |
endif | |
" if has('gui_win32') | |
" noremap <silent><S-Esc> :simalt ~n<CR> | |
" endif | |
""" QuickFix: Development/Compile <F9> {{{2 | |
nmap <silent><C-F9> :wall<BAR>cclose<BAR>silent make<BAR>botright cwindow 4<CR> | |
nmap <silent><F9> :botright cwindow 4<BAR>cnext<CR>zv | |
nmap <silent><S-F9> :botright cwindow 4<BAR>cprev<CR>zv | |
""" VimTip94: :ptjump on the tag | |
" map <C-]> <C-W>g} | |
" map <C-Z>] <C-W>g<C-]> | |
""" Show Tags | |
" map <F4> :silent ptag <C-R><C-W><CR> | |
""" Mode Switch: {{{2 | |
nmap <silent><F3> :setlocal wrap! wrap?<CR> | |
nmap <silent><M-F3> :setlocal list! list?<CR> | |
" nmap <silent><C-F3> :setlocal number! number?<CR> | |
nmap <silent><C-F3> :if(&l:nu)<BAR>setl rnu rnu?<BAR>elseif(&l:rnu)<BAR>setl rnu! nu?<BAR>else<BAR>setl nu nu?<BAR>endif<CR> | |
nmap <silent><S-F3> :setlocal hlsearch! hlsearch?<CR> | |
nmap <silent><C-S-F3> :setlocal cursorline! cursorcolumn! cursorcolumn?<CR> | |
""" Folding: {{{2 | |
""" Hide/show fold column | |
nmap <silent>zi zi:let &l:fdc=&l:fen*&g:fdc<CR> | |
nmap <silent>zZ :<C-U>let &l:fdc=v:count<CR> | |
""" Tip1330: Easily open and close folds | |
nmap <expr><Space> foldclosed('.')==-1?'l':'za' | |
" nmap <Space> za | |
" nmap <CR> zozt | |
" nmap <Esc> zczz | |
""" Goto next/prev folder | |
nmap <M-PageDown> zjzvzt | |
nmap <M-PageUp> zkzv[zzt | |
""" Fold an entire block of code | |
map <kPoint> v%zf | |
""" View cursor line only | |
nmap zV zMzx | |
""" More/Reduce folding level | |
nnoremap <S-kPlus> zm | |
nnoremap <S-kMinus> zr | |
""" Lines: Copy/Move/Swap {{{2 | |
""" have Y behave analogously to D rather than to dd | |
nmap Y y$ | |
""" With no selection - copy current line | |
nmap <C-Insert> "+yy | |
imap <C-Insert> <C-O>"+yy | |
cmap <C-Insert> <C-Y> | |
""" Move lines up/down | |
nmap <silent><C-Down> :move +1<CR> | |
imap <C-Down> <C-O><C-Down> | |
vmap <silent><C-Down> :move <C-R>=line("'>")+1<CR><CR><C-\><C-N>gv | |
map <silent><C-Up> :move -2<CR> | |
imap <C-Up> <C-O><C-UP> | |
vmap <silent><C-Up> :move -2<CR><C-\><C-N>gv | |
""" Copy chars from prev/next line | |
inoremap <C-Space> <C-Y> | |
inoremap <C-S-Space> <C-E> | |
""" Copy line - like yyp , but keep cursor position | |
nmap <silent><C-Z>z :copy .<CR> | |
imap <silent><C-Z>z <C-O><C-Z>z | |
""" Add selection to clipboard | |
vnoremap <silent><C-kPlus> :<C-U>let @c=@*<CR><C-\><C-N>gv"Cy:let @*=@c<CR> | |
""" Copy whole bubber to clipboard | |
nmap <C-Z><C-Insert> :%yank *<CR> | |
""" Meta-A is Select all | |
nnoremap <M-a> ggVG | |
""" Copy current word to the clipboard | |
nnoremap <M-Insert> "*yiw | |
""" Change current word with clipboard | |
" nnoremap <M-C-Insert> ciw<C-R>*<ESC> | |
""" CursorKeys: use screen lines {{{2 | |
""" editing mapping (make cursor keys work like in windows. | |
""" ie: <C-Left><C-Right> move to next word. | |
nmap <C-Left> b | |
vmap <C-S-Left> b | |
nmap <C-S-Left> vb | |
imap <C-S-Left> <C-O>vb | |
if &sel == 'exclusive' | |
nmap <C-Right> w | |
vmap <C-S-Right> w | |
nmap <C-S-Right> vw | |
imap <C-S-Right> <C-O>vw | |
else | |
nmap <C-Right> e | |
vmap <C-S-Right> e | |
nmap <C-S-Right> ve | |
imap <C-S-Right> <C-O>ve | |
endif | |
nnoremap <M-Up> <C-E> | |
nnoremap <M-Down> <C-Y> | |
""" Indenting: {{{2 | |
""" In visual mode, <TAB> will shift the block and restore selection | |
""" <S-TAB> will do the same thing, going backward. | |
vmap <Tab> >gv | |
vmap <S-Tab> <LT>gv | |
nmap <Tab> >> | |
nmap <S-Tab> <LT><LT> | |
inoremap <S-Tab> <C-D> | |
""" Encodings: i18n & l10n {{{2 | |
function! s:FEncNext() " // File Encoding switching | |
let b:encstring = (!exists("b:encstring"))? substitute(&fencs, ',', ' ', 'g') : b:encstring | |
if &fenc=='' | let &l:fenc=&enc | return | endif | |
""" place current fenc to the end of the string | |
let b:encstring = substitute(b:encstring, '^\v(.*<'. &fenc .'>)\s+(.*)$', '\2 \1', '') | |
let nenc = substitute(b:encstring, '^\v\s*(\S+).+', '\1', '') | |
if expand('%') == '' | |
let &l:fenc=nenc | |
else | |
silent exec 'vi ++enc=' . nenc | |
endif | |
endfunction | |
map <silent><F8> :call <SID>FEncNext()<CR> | |
""" Switch LangMap: | |
nmap <silent><M-Space> :let &imi=!&imi<CR> | |
nmap <silent><M-Space> :let &imi=!&imi<CR> | |
map! <M-Space> <C-^> | |
""" SwitchCase: {{{2 | |
imap <silent><Plug>SwitchCase <C-R>=(@@==#toupper(@@))?tolower(@@):(@@==#tolower(@@))?substitute(@@,'\<.','\u&',''):toupper(@@)<CR><C-O>`] | |
nmap <M-\> ciw<Plug>SwitchCase | |
vmap <M-\> c<C-\><C-N>i<Plug>SwitchCase<ESC>gv | |
imap <M-\> <ESC>ciW<Plug>SwitchCase | |
""" Digraphs: {{{2 | |
dig \- 173 " Soft Hyphen: ­ (TeX/LaTeX: \- ) | |
dig \` 768 " Grave Accent (TeX/LaTeX: \` ) | |
dig \' 769 " Acute Accent (TeX/LaTeX: \' ) | |
dig ** 8226 " • | |
dig .. 8230 " … (TeX/LaTeX: \ldots) | |
" dig <space><space> 160 " TeX/LaTeX: Type a tilde, ~ | |
""" Insert DateTime FileName: {{{2 | |
imap <silent><C-Z><C-D> <C-R>=strftime('%Y-%m-%d')<CR> | |
imap <silent><C-Z><C-T> <C-R>=strftime('%H:%M')<CR> | |
imap <silent><C-Z># <C-R>='@(#) '.expand('%:p:~')<CR> | |
imap <silent><C-Z><C-V> <C-R>='vim: set ft='.&ft.' ts='. &ts . ' noet fenc=' . &fenc . ':'<CR> | |
imap <silent><C-Z><C-C> <C-R>='(c) '.copyright<CR> | |
imap <silent><C-Z><C-M> <C-R>=strftime('mitry @ %Y-%m-%d: ')<CR> | |
imap <silent><C-Z><C-U> <C-R>=user.' <'.replyto.'>'<CR> | |
imap <silent><C-Z><C-E> <C-R>=replyto<CR> | |
imap <silent><C-Z><C-G> [email protected] | |
map! <C-R><C-D> <C-R>=expand("%:p:h")<CR>/ | |
map! <C-R><C-E> <C-R>=expand("%:p:~:.:h")<CR>/ | |
map! <C-R><C-G> <C-R>=getcwd()<CR>/ | |
""" Command Mode Abbrs: {{{2 | |
cabb E echo | |
cnoremap E<S-Space> echo<space> | |
cmap <C-CR> <C-R><C-W> | |
cmap :: %s!!!g<Left><Left><Left> | |
cmap :; .,$s!!!g<Left><Left><Left> | |
cmap <C-Q> \(.\{-}\) | |
""" Escape commandline: | |
cmap <M-q> <C-\>eescape(getcmdline(), ' \')<CR> | |
""" Copy to clipboard: | |
cmap <C-Insert> <C-R>=setreg('*',getcmdline())?'':''<CR> | |
""" Insert current line: | |
cmap <C-R><C-L> <C-R>=strtrans(getline('.'))<CR> | |
""" Delete the word after cursor | |
cmap <C-Delete> <C-\>esubstitute(getcmdline(), '\%'.getcmdpos().'c\k\+\s*', '','')<CR> | |
""" Paths | |
cnoremap <C-Space> <C-R>=expand("%:p:.:~:h")<CR>/<TAB> | |
cnoremap <C-S-Space> ~/.vim/<TAB> | |
cnoremap <M-1> ~/.vim/<TAB> | |
cnoremap <M-2> $VIMRUNTIME/<TAB> | |
cnoremap <M-3> ~/src/<TAB> | |
cnoremap <M-4> /usr/src/<TAB> | |
cnoremap <M-9> ~/.vim/ftplugin/<C-R>=&ft<CR><TAB><TAB> | |
""" Edit Files: {{{2 | |
""" Forcebly edit file under cursor | |
nmap <Leader>gf :try<bar>find <lt>cfile><bar>catch<bar>edit <lt>cfile><bar>endtry<cr> | |
nmap <Leader><Leader>e :e <C-R>=expand("%:p:~:.:h")<CR>/<Tab> | |
nmap <Leader><Leader>v :sp ~/.vim/.vimrc<CR> | |
nmap <Leader><Leader>M :sp ~/.vim/menu.vim<CR> | |
nmap <Leader><Leader>p :sp ~/.passwd<CR> | |
nmap <Leader><Leader>g :sp ~/GTD/<Tab> | |
""" Show ToDo list in preview window: | |
nmap <Leader><Leader>o :pedit ~/.plan<CR><C-W>P4<C-W>_ggO | |
""" Open filefype plugin in preview window: | |
nmap <Leader><Leader>T :pedit `=exists('b:my_ftplugin')? b:my_ftplugin : '~/.vim/ftplugin/'.&ft.'.vim'`<CR><C-W>P:set ro nowinfixheight<CR><C-W>_ | |
""" Scratch | |
nmap <Leader><Leader>s :tabnew +setl\ bt=nofile\ fdc=0<CR> | |
""" Template/snippets: | |
nmap <Leader><Leader>t :read ~/.vim/templates/<C-R>=&ft<CR>/<TAB> | |
vmap <Leader><Leader>t :write ~/.vim/templates/<C-R>=&ft<CR>/ | |
nmap <Leader><Leader>m :sfind Makefile<CR> | |
""" Abbreviations: {{{2 | |
iabbr dM <C-R>=user.' <'.replyto.'>'<CR> | |
iabbr NEO Nomen est omen | |
""" Exec File: {{{2 | |
if has('win32') | |
command! -nargs=+ ShExec :exe 'silent!!start' 'NirCmd.exe shexec open "'.iconv(expand(<q-args>),&enc,'cp1251').'"' | |
nmap <silent>gx :ShExec <cfile>:p<CR> | |
vmap <silent>gx y:ShExec <C-R>"<CR> | |
map <silent>gX :ShExec %:p<CR> | |
map <silent><C-F10> gX | |
map <M-F12> :silent!!start c:/opt/far2/far.exe /i /c %:p:h:gs?/?\\?<CR> | |
" Copy current file name to clipboard | |
nnoremap <M-C-Insert> :let @*=expand('%:p')<CR> | |
nnoremap <M-S-Insert> :if filereadable(fnamemodify(@*,':gs?"??'))<BAR>tabedit <C-R>=fnamemodify(@*,':gs?"??')<CR><BAR>endif<CR> | |
" nnoremap <M-S-Insert> :if tabedit <C-R>*<CR> | |
if executable('NirCmd.exe') | |
""" Jump to regkey in the RegEdit via NirCmd | |
map <silent>gy :silent!!start NirCmd.exe regedit <cfile>:s?^\[\|]$??:s?^-??<CR> | |
""" Make link to the current file on the desktop | |
map <silent><M-F6> :silent!!start NirCmd.exe shortcut "%:p" "~$folder.desktop$" "%:p:t:r"<CR> | |
endif | |
endif " has('win32') | |
""" GUI: {{{2 | |
if has('gui') | |
""" Toggle GUI Option: | |
function! s:SwitchGui(opt) | |
exe "set go".(&go =~# a:opt? '-=' : '+=').a:opt | |
set lines=999 | |
endfunc | |
""" Switch Main GUI Menu: | |
nmap <silent><M-F10> :call <SID>SwitchGui('m')<CR> | |
nmap <silent><S-F10> :call <SID>SwitchGui('T')<CR> | |
""" Increase/Decrease Fontsize: | |
""" @see http://vim.wikia.com/wiki/VimTip760 | |
nnoremap <C-kPlus> :let &gfn=substitute(&gfn,':h\zs\d\+','\=eval(submatch(0)+1)','')<bar>set lines=999<CR> | |
nnoremap <C-kMinus> :let &gfn=substitute(&gfn,':h\zs\d\+','\=eval(submatch(0)-1)','')<bar>set lines=999<CR> | |
endif | |
""" =============================== }}}2 | |
""" Copy full-file-name to clipboard | |
nmap <C-S-Insert> :let @*=expand("%:p")<CR> | |
""" Smart Home: | |
nnoremap <expr><Home> matchend(getline('.'),'^\s*')<col('.')-1? '^':'0' | |
inoremap <expr><Home> pumvisible()? "\<Home>" : matchend(getline('.'),'^\s*')<col('.')-1? '^':'0' | |
""" Smart Tab: completion | |
" inoremap <expr><Tab> getline('.')[0:col('.')-1]!~'\k$'? "\<Tab>":"\<C-n>" | |
""" Start block selection: | |
nnoremap <C-V><C-V> <C-V>$ | |
""" Browser-like History Navigation: | |
nnoremap <M-Right> <C-I>zv | |
nnoremap <M-Left> <C-O>zv | |
""" Add line in insert mode: | |
inoremap <S-CR> <C-O>O | |
inoremap <C-CR> <C-O>o | |
""" Quick insert 1 char: | |
nnoremap <M-i> i<SPACE><ESC>r | |
""" Disable <C-Z> - suspend vim | |
map <C-Z> <NOP> | |
map! <C-Z> <NOP> | |
""" Correct syntax synchronization | |
map <Leader><Leader>r :syntax sync fromstart<CR> | |
""" VimTip44: The last command-line change (those invoked with ":", | |
""" e.g. :s/foo/bar ) can be repeated with the "@:" command. | |
map <F5> @: | |
""" VimTip637: execute accidently inserted commands | |
""" If you are in insert mode and typed an command for normal mode, you can | |
""" use it. This mapping switches to normal mode, undo'es the last insertion | |
""" and takes it as a command. | |
inoremap <C-ESC> <ESC>u@. | |
""" Puts "" around the word under cursor or the visual selected area | |
nnoremap <C-Z>" ciw"<C-r>""<ESC> | |
vnoremap <C-Z>" c"<C-r>""<ESC> | |
nnoremap <C-Z>' ciw'<C-r>"'<ESC> | |
vnoremap <C-Z>' c'<C-r>"'<ESC> | |
nnoremap <C-Z>) ciw(<C-r>")<ESC> | |
vnoremap <C-Z>) c(<C-r>")<ESC>`[ | |
""" Swap the current and preceeding word at the line end | |
nmap <Leader><BS> daWgepe | |
""" don't use ex mode, use q for line formatting | |
nmap Q gw} | |
vmap Q gq | |
""" Format block of lines | |
nmap g= =g% | |
map <M-=> =g% | |
""" Visually select the last copy/pasted text (didn't work ?) | |
nnoremap <M-v> `[v`] | |
inoremap <M-v> <C-O>`[v`] | |
""" Duplicate current line and in/decriment | |
nmap <M-a> :copy .<CR><C-A> | |
nmap <M-x> :copy -<CR><C-X> | |
"""" Underline with some symbol | |
nnoremap <Leader>h yypVr | |
"echo "Key mapping done!!!" | |
"========================== | |
""" Commands: {{{1 | |
""" Redir: Copy vim command output to the system clipboard {{{2 | |
command! -nargs=+ -complete=command Redir | |
\ redir @a | |
\ | silent <args> | |
\ | redir END | |
\ | 20new [Scratch: <q-args>] | |
\ | 1put! a | |
\ | setlocal bh=delete bt=nofile nomod | |
\ | wincmd p | |
""" CD: to the dir of the current buffer for current window {{{2 | |
command! CD lcd %:p:h | |
command! Cd lcd %:p:h | |
""" Info: {{{2 | |
""" Define Info cmd to source script file which redefine this one | |
command! -nargs=* Info | |
\ delcommand Info | | |
\ runt scripts/Info.vim | | |
\ Info <args> | |
""" Man: {{{2 | |
""" Define Man cmd to source script file which redefine this one | |
command! -nargs=1 Man | |
\ delcommand Man | | |
\ runt ftplugin/man.vim | | |
\ Man <args> | |
""" WinHelp: Invoke Windows help {{{2 | |
if has('win32') | |
command! -nargs=1 -complete=file WinHelp | |
\ call libcallnr(expand('~/.vim/etc/wvimhlp.dll',1), 'winhelp', | |
\ <q-args> . '|' . iconv(expand('<cword>'), &enc, 'cp1251')) | |
endif | |
""" Encoding: Change file encoding {{{2 | |
command! -nargs=1 -bar Encoding if &fenc!=<q-args> | visual ++enc=<args> | endif | |
""" InsClip: insert clipboard as 1st item of the list in the buffer {{{2 | |
"" usage: gvim --remote-silent-tab +InsClip ~/.plan | |
command! -bar InsClip 1/^\s*\*/|exe"norm!O\<C-R>*"|write | |
""" Post To Twitter: {{{2 | |
command! -range Twitter <line1>,<line2>write ++enc=UTF-8 !curl --data-urlencode status@- --netrc --no-remote-name https://twitter.com/statuses/update.xml | |
""" ====================================== }}}1 | |
source ~/.vim/menu.vim " My customized menu | |
" runt! menu.vim | |
"runtime etc/wordlist.vim " common english misstypes | |
" set noexrc " enable reading .vimrc/.exrc/.gvimrc in the current directory | |
set secure " safer working with script files in the curdir | |
" EOF ~/.vim/.vimrc // vim: fen:fdm=marker:fcl=all:fdl=0:fml=1:ts=8:ff=unix: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment