vimrc Description vim имеет всего два режима бибикать все портить Auth

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
" @(#) ~/.vimrc
" Description: vim имеет всего два режима - бибикать и все портить. :-)
" Author: dMitry Alexandrow <dmitry.alexandrow (at) gmail.com>
" Created: 2003-08-24
" Version: $Id: .vimrc,v 1.59 2008/01/20 23:03:42 SYSTEM Exp $
version 6.2
" 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
" Store an editing session in the viminfo file; can be used at next session.
set sessionoptions=buffers,folds,sesdir,slash,unix
set viminfo='50,<10,f1,s1,%,!,n~/.vim/.viminfo
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
let g:ausession= ".vimsession" " file for autosaved session
" 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=gmMr " 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
" Tab support for 7.+ version
if has('windows')
set guioptions+=e
set switchbuf+=usetab
set sessionoptions+=tabpages
endif
if has("gui_win32")
" set guifont=Andale_Mono:h8:cRUSSIAN
" set guifont=Lucida_Console:h10:cRUSSIAN
" set guifont=Lucida_Sans_Typewriter:h8:cRUSSIAN
" set guifont=Courier_New:h10:cDEFAULT
" set guifont=Liberation_Mono:h10:cRUSSIAN
set guifont=DejaVu_Sans_Mono:h10:cRUSSIAN lines=999 columns=100
" set columns=100
endif
" Windows: {{{2
set noequalalways " don't make all windows the same size when adding/removing windows
" 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 " which window to use when jumping
set nowinfixheight " don't keep the height of the window
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 of the help window
" let &winheight=has('gui')? &lines-10 : 20
let &winheight=has('gui')? 35 : 20
" statusline:
let &stl='--<%02n> %1*%t%* %3*%M%*[%(%R%W%Y%),%{&fenc}:%{&ff}] %2*%{mode()}%* %4*%k%* %= 0x%B at %1*%l%*/%L:%c%V --'
set laststatus=2 " Always a status line
" Moving Around Searching And Patterns: {{{2
"set path=,;~/** " list of directory names used for file searching
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 nowrapscan " 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')
" list of strings used for list mode
let &listchars = 'tab:|' . nr2char(0xBB) . ',trail:' .nr2char(0xB7) . ',eol:$'
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
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
" N number of spaces
" Ns number of spaces * shiftwidth
" >N default indent
" eN extra indent if the { is at the end of a line
" nN extra indent if there is no {} block
" fN indent of the { of a function block
" gN indent of the C++ class scope declarations (public, private, protected)
" {N indent of a { on a new line after an if,while,for...
" }N indent of a } in reference to a {
" ^N extra indent inside a function {}
" :N indent of case labels
" =N indent of case body
" lN align case {} on the case line
" tN indent of function return type
" +N indent continued algibreic expressions
" cN indent of comment line after /*
" (N indent N characters from the line with the unclosed parentheses.
" )N vim searches for closing )'s at most N lines away
" *N vim searches for closing */ at most N lines away
" 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,*.class,*.au,*.wav,*.mp[23g],*.jar,*.rar,*.zip,*/CVS/,*/.hg/,*.~*,*~
" Ignore with `:edit` command:
set suffixes=.aux,.bak,.dvi,.class,.idx,.log,.ps,.swp,.gz,.tgz,*.rar,.zip,.exe,.dll,.com,.obj,.chm,.out,.COPYING,tags
" 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
so <sfile>:p:h/keymap/russian-jcuken-win.vim
if has('win32') && !has("gui_running") && $SHELL != ''
set termencoding=8bit-cp1252
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
" Colors And Position: {{{1
" Color scheme must be loaded _before_ `syntax on`
if has("gui_win32")
colorscheme MSWin
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
silent exe a:str
normal! g``zv
call histdel("/", -1)
let @/ = histget("/", -1)
endif
endfunction " }}}2
augroup ENCODINGS " {{{2
au!
" au BufNewFile * setl fenc=cp1251
" au BufNewFile *.ini setl fenc=cp1251
au FileType jproperties nested Encoding java
au FileType mail nested Encoding koi8-r
" au FileType dosini nested Encoding cp1251
" To show lang name on the statusline
au BufNewFile,BufRead * let b:keymap_name="RU"
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
" Restore last known position.
au BufReadPost * silent! exe line("'\"")? 'norm! g`"zv' : ''
au FileType log setlocal autoread
" 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
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 BufRead ~/.passwd setl syn=url fdm=expr fde=outline#fold()
if executable('pwgen') == 1
au BufRead ~/.passwd nno <buffer><silent><LocalLeader>p "=substitute(system('pwgen'),'\n$','','')<CR>p
elseif executable('makepasswd') == 1
au BufRead ~/.passwd nno <buffer><silent><LocalLeader>p "=substitute(system('makepasswd -l 12'),'\n$','','g')<CR>p
elseif executable('perl') == 1
au BufRead ~/.passwd nno <buffer><silent><LocalLeader>p "=substitute(system('perl -MText::Password::Pronounceable -e "print Text::Password::Pronounceable->generate(8, 10)"'),'\n$','','')<CR>p
endif
" au BufRead ~/.passwd nno <buffer><silent><LocalLeader>p "=substitute(system('cscript.exe //NoLogo c:/bin/pwgen.js'),'\n$','','g')<CR>p
au BufRead ~/.passwd imap <buffer><silent><LocalLeader>p <C-O><LocalLeader>p
au BufRead ~/.passwd nno <buffer><C-Ins> "*yiW
au BufRead ~/GTD/* setf vimwiki
au BufRead *.m3u,*.pls nno <buffer>gx :!start /usr/opt/mplayer/mplayer -nocache <C-R><C-F><CR>
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 syn clear WhitespaceEOL
au Syntax *.[ch],*.[ch]pp runtime syntax/doxygen.vim
augroup END
augroup SESSSIONS " {{{2
au!
au VimEnter * nested if !strlen(v:this_session) && !argc() && !expand("<client>") && filereadable(g:ausession) | exec 'so' g:ausession | endif
au VimLeavePre * if strlen(v:this_session)
au VimLeavePre * let SESSION = v:this_session
au VimLeavePre * exe 'mksession!' v:this_session
if has('win32')
au VimLeavePre * exe 'silent!!start NirCmd.exe shortcut "'.v:this_session'" "~$folder.desktop$\Projects" '.fnamemodify(v:this_session,':p:h:t:r')
endif
au VimLeavePre * else
au VimLeavePre * silent! unlet SESSION
au VimLeavePre * endif
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!
"au VimLeave *.asc :!clear
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! rundll32.exe shell32.dll,ShellExec_RunDLL <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"
" \ SExe! RunDll32.exe shell32.dll,ShellExec_RunDLL "<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
" Plugins: {{{1
let user = 'dMitry Alexandrov' " used by Templates
let replyto = 'dmitry.alexandrow@gmail.com' " - '' -
let copyright = strftime("%Y").', Mitrysoft Corp. All rights reserved.'
let username = 'Mitry' " used by JCommenter
let spec_chglog_format = '%Y-%n-%d ' .user.' <'.replyto.'>'
" -------------
" Environment:
let $EDITOR = (has('gui_running')?'g':'') . 'vim --remote-silent'
let $MAIL = 'Inbox.mbx' " Used by mailbrowser
let $TERM = has('gui')? 'dump' : $TERM
" 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: (cp-1251) {{{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 loaded_cvscommand = 1 " Don't load
let CVSCommandDeleteOnHide=1 " automatically delete temporary CVS results
let CVSCommandDiffOpt='wbBu' " options passed to the diff command (fefault: wbBc)
let CVSCommandEdit='split' " the original buffer is replaced ('edit') or split
let CVSCommandEnableBufferSetup=0 " set 'CVSRevision' 'CVSBranch' vars
" Mru: {{{2
let MRU_File = '~/.vim/.mru_files'
"let MRU_Max_Entries=20
" 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
" EnhancedCommentify: {{{3
let EnhCommentifyRespectIndent='yes' " - yes/no - in lowcase ?!?!
let EnhCommentifyPretty='yes' " -
let EnhCommentifyUseSyntax='yes' " -
let EnhCommentifyUseBlockIndent='yes' " -
let EnhCommentifyMultiPartBlocks='yes' " - Mulitline-comments
"let EnhCommentifyUseAltKeys='no' " Use alt keybindings <Meta-X> instead of <Leader>X.
"let EnhCommentifyUserBindings='yes' " -
nmap <silent><M-`> <Plug>Traditional<C-\><C-N>j
imap <M-`> <ESC><M-`>i
vmap <silent><M-`> <Plug>VisualTraditional<C-\><C-N>gv
" Copy current line and commentify it
nmap <silent><C-Z><C-Z> :copy -1<CR><M-`>
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 ???
" ====================================== }}}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
" 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>
map <C-S-F1> <Leader><Leader>?
" Show buffer key mappings
map <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
nmap <C-C> ciw
" 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
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 <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
" Jump between windows
nnoremap <C-W><C-W> <C-W>p
" 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>
" WinTabs support
if has('windows')
nnoremap <F6> <C-W>^<C-W>T
" nnoremap <silent><S-Esc> :simalt ~n<CR>
" nnoremap <silent><F4> :tabnew<CR>
map <C-Tab> gt
map <C-S-Tab> gT
map <C-W><Tab> gt
map <C-W><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
else
map <C-Tab> :sbuffer<Space><Tab><Tab>
map <C-S-Tab> <C-^>
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><S-F3> :setlocal hlsearch! hlsearch?<CR>
" Insert/Normal mode switching
" map <silent><F12> :set insertmode! im?<CR>
" Folding: {{{2
" Hide/show fold column
nmap zi zi:let &l:fdc=&l:fen*&g:fdc<CR>
nmap zZ :<C-U>let &l:fdc=v:count<CR>
" Tip#1330: Easily open and close folds
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
" 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
noremap <M-A> ggVG
" Copy current word to the clipboard
noremap <M-Insert> "*yiw
" Change current word with clipboard
nmap <M-S-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><F12> :set im<CR><C-^><C-O>:set noim<CR>
map! <F12> <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
map <Plug>SxCase ciw
" Digraphs: {{{2
dig ** 8226 " &bull;
dig .. 8230 " &hellip
" dig <space><space> 160 " &nbsp;
" 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-F> <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-R> <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 <C-R><C-D> <C-R>=expand("%:p:h")<CR>/
imap <C-R><C-E> <C-R>=expand("%:p:~:.:h")<CR>/
nmap <C-Z><C-D> i<C-Z><C-D><ESC>
nmap <C-Z><C-T> i<C-Z><C-T><ESC>
nmap <C-Z><C-F> i<C-Z><C-F><ESC>
nmap <C-Z><C-V> i<C-Z><C-V><ESC>
nmap <C-Z><C-R> i<C-Z><C-R><ESC>
nmap <C-Z><C-X> i<C-Z><C-X><ESC>
nmap <C-Z><C-U> i<C-Z><C-U><ESC>
" copy full-file-name to clipboard
nmap <C-S-Insert> :let @*=expand("%:p")<CR>
" Command Mode Abbrs: {{{2
cabb E echo
cnoremap E<S-Space> echo<space>
cmap <C-Space> ~/.vim/<tab>
cmap <S-Space> %s!!!g<Left><Left><Left>
cmap <C-S-Space> .,$s!!!g<Left><Left><Left>
cmap <C-Q> \(.\{-}\)
" Escape commandline:
cmap <F8> <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>
" Insert paths
cmap <C-R><C-D> <C-R>=expand("%:p:h")<CR>/
cmap <C-R><C-E> <C-R>=expand("%:p:~:.:h")<CR>/
cmap <C-R><C-G> <C-R>=getcwd()<CR>/
cmap <C-R><C-T> ~/.vim/ftplugin/<C-R>=&ft<CR><TAB><TAB>
cmap <C-R><C-V> ~/.vim/<TAB>
" Paths
cnoremap <M-`> <C-R>=expand("%:p:~:.:h")<CR>/
cnoremap <M-1> ~/.vim/<TAB>
cnoremap <M-2> $VIMRUNTIME/<TAB>
cnoremap <M-3> ~/src/<TAB>
cnoremap <M-4> /usr/src/<TAB>
" Edit Files: {{{2
" // Forcebly edit file under cursor
" nmap <Leader>gf :edit %:p:h/<cfile><cr>
" nmap <Leader>gf :try<bar>find <lt>cfile><bar>catch<bar>edit %:p:h/<lt>cfile><bar>endtry<cr>
nmap <Leader>gf :try<bar>find <lt>cfile><bar>catch<bar>edit <lt>cfile><bar>endtry<cr>
nmap <Leader><Leader>v :sp ~/.vim/.vimrc<CR>
nmap <Leader><Leader>V :sp ./.vimrc<CR>
nmap <Leader><Leader>M :sp ~/.vim/menu.vim<CR>
nmap <Leader><Leader>p :sp ~/.passwd<CR>
" nmap <Leader><Leader>o :sp ~/.plan<CR>
nmap <Leader><Leader>o :sp ~/GTD/@someday<CR>
nmap <Leader><Leader>O :sp `=g:diary_file`<CR>
nmap <Leader><Leader>T :pedit `=exists('b:my_ftplugin')? b:my_ftplugin : '~/.vim/ftplugin/'.&ft.'.vim'`<CR><C-W>P
nmap <Leader><Leader>d :sp ++enc=cp866 ~/Desktop/2down.lst<CR>
nmap <Leader><Leader>e :e <C-R>=expand("%:p:~:.:h")<CR>/<Tab>
" Scratch
nmap <Leader><Leader>s :tabnew +setl\ bt=nofile<cr>
" Edit vimsession-extra file:
nmap <Leader><Leader>X :sp `=fnamemodify(v:this_session,':p:r').'.x.vim'`<CR>
nmap <Leader><Leader>S :exe exists('SESSION')? 'so '.SESSION : 'echoerr "No last session known!"'<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>
if has('win32') && isdirectory('c:/var/log/cron/')
nmap <Leader><Leader>n :pedit ++enc=cp1251 +$ c:/var/log/cron/<C-R>=strftime('nnCron%m%d.log')<CR><CR>
endif
" Complition {{{2
if v:version >= 700
" ** These two mappings are probably the most rare, yet most valuable: **
inoremap <expr><c-n> pumvisible()? "\<lt>c-n>" : "\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"
inoremap <expr><c-p> pumvisible()? "\<lt>c-n>" : "\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>up>\" : \"\"\<lt>cr>"
" inoremap <expr><m-;> pumvisible()? "\<lt>c-n>" : "\<lt>c-x>\<lt>c-o>\<lt>c-n>\<lt>c-p>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"
endif
" Abbreviations: {{{2
iabbr dM <C-R>=user.' <'.replyto.'>'<CR>
iabbr NEO Nomen est omen
" Exec File: {{{2
if has('win32')
" command Sh :call system('RunDll32.exe shell32.dll,ShellExec_RunDLL "'.iconv(expand(<q-args>),&enc,'cp866').'"')
command! -nargs=* Sh :exe 'silent !start' 'RunDll32.exe shell32.dll,ShellExec_RunDLL "'.iconv(expand(<q-args>),&enc,'cp1251').'"'
nmap <silent>gx :silent !start RunDll32.exe shell32.dll,ShellExec_RunDLL <cfile><CR>
" nmap <silent>gX :silent !start RunDll32.exe shell32.dll,ShellExec_RunDLL "%:p"<CR>
" nmap <silent>gX :call system('RunDll32.exe shell32.dll,ShellExec_RunDLL "'.iconv(expand('%:p'),&enc,'cp866').'"')<CR>
nmap <silent>gX :exe 'silent !start' 'RunDll32.exe shell32.dll,ShellExec_RunDLL "' . iconv(expand('%:p'),&enc,'cp1251') . '"'<CR>
map <silent><C-F10> gX
map <M-F12> :silent!!start c:/opt/far/far.exe /i /c %:p:h:gs?/?\\?<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>
" Make link to the current session on the desktop
map <silent><S-F6> :if strlen(v:this_session)
\ <BAR> exe ':silent!!start NirCmd.exe shortcut "'.v:this_session'" "~$folder.desktop$\Projects" '.fnamemodify(v:this_session,':p:h:t:r')
\ <BAR> else <BAR> echoerr "No session!!" <BAR> endif<CR>
endif
endif
" GUI: {{{2
if has('gui')
" Switch GUI Option:
function! s:SwitchGui(opt)
exe "set go".(&go =~# a:opt? '-=' : '+=').a:opt
set lines=999
endfunc
" Switch Main GUI Menu:
nmap <silent><F10> :call <SID>SwitchGui('m')<CR>
nmap <silent><S-F10> :call <SID>SwitchGui('T')<CR>
" map <silent><F10> :if &go =~#'m'\|set go-=m\|else\|set go+=m\|endif\|set lines=999<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
" Start block selection:
nnoremap <C-V><C-V> <C-V>$
" Restore ability to use <C-I> redefined by indeneting with <Tab>
nnoremap <M-Right> <C-I>zv
nnoremap <M-Left> <C-O>zv
inoremap <C-CR> <C-O>O
inoremap <S-CR> <C-O>o
" Auto-completion assigned
inoremap <M-Space> <C-X><C-V>
" Quick insert 1 char
nnoremap <M-i> i<SPACE><ESC>r
" Quick paste
inoremap <M-p> <C-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>
" ======================================
"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'), '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
" Far: invoke far manager {{{2
if has('win32')
command! -nargs=0 -bar Far :silent!!start c:/opt/far/far.exe -i %:p:h
endif
" Move (append) lines to the other file {{{2
" Usage: :{range}Move [file_name]
command! -complete=file -range -bang -nargs=? Move :<line1>,<line2>write<bang> >> <args>|:<line1>,<line2>delete
" ====================================== }}}1
source ~/.vim/menu.vim " My customized menu
" runt! menu.vim
"runtime etc/wordlist.vim " common english misstypes
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:fenc=cp1251:ff=unix: