]> git.phdru.name Git - dotfiles.git/blob - .vimrc
.vimrc: use matchit plugin
[dotfiles.git] / .vimrc
1 " User configuration file for Vi IMproved.
2 "
3 " vim 6.0+ required, 7.0+ recommended.
4
5 " 1 important
6
7 " Remove ALL autocommands in case the file is sourced for the second time
8 autocmd!
9
10 language messages C " Print messages in English
11
12 if exists("b:wrap") " Only do this on the second and subsequent :source's
13    let fenc = &fileencoding
14    let ftype = &filetype
15    let mod = &modified
16    set all& " Reset all options, except terminal options, to their default value.
17    execute 'set fileencoding=' . fenc
18    execute 'set filetype=' . ftype
19    if mod
20       set modified
21    else
22       set nomodified
23    endif
24    unlet fenc ftype mod
25 endif
26
27 " No, it is not VI, it is VIM! It is important to set this first, because this
28 " command resets many other options.
29 set nocompatible
30
31 " Set behavior to xterm, not mswin
32 behave xterm
33
34 " 2 moving around, searching and patterns
35
36 set ignorecase    " Ignore case in search patterns
37 set smartcase     " Match 'word' case-insensitive and 'Word' case-sensitive
38
39 set nostartofline " Keep cursor's column
40 set whichwrap=b,s,h,l,<,>,[,],~ " Wrap to the previous/next line on all keys and ~ command
41
42 " 4 displaying text
43
44 set display=lastline,uhex " Show the last line instead of '@'; show non-printable chars as <hex>
45 set lazyredraw    " Do not update screen while executing macros
46 set list          " listchars only works with 'list'
47 set listchars=tab:>_,trail:_,extends:+ " Show tabs, trailing spaces, long lines
48 set wrap          " Visually wrap long lines
49
50 " With 'set wrap' wrap long lines at a character in 'breakat'
51 " Please note 'nolist' is required to use 'linebreak'
52 set linebreak showbreak=+\ " A plus and a space
53
54 set sidescroll=1  " The minimal number of columns to scroll horizontally
55
56 " 5 highlighting
57
58 set nohlsearch    " Stop the search highlighting
59
60 " 6 multiple windows
61
62 set hidden        " Don't unload a buffer when no longer shown in a window; allow to switch between buffers/windows when the buffer is modified
63 set laststatus=2  " Always show status line
64
65 set splitbelow    " A new window is put below of the current one
66 set splitright    " A new window is put right of the current one
67
68 " 8 terminal
69
70 set ttyfast       " terminal connection is fast
71
72 set title         " Set title to the value of 'titlestring' or to 'filename - VIM'
73 set titleold=     " string to restore the title to when exiting Vim
74
75 " 9 using the mouse
76
77 set mouse=ar      " Use mouse in all modes, plus hit-return
78
79 " 12 messages and info
80
81 set ruler         " Show cursor position below each window
82 set showcmd       " Show (partial) command keys in the status line
83
84 " Short message for [Modified];
85 " overwrite message for writing a file with subsequent message;
86 " truncate long file messages
87 set shortmess=mot
88
89 " 14 editing text
90
91 set backspace=indent,eol,start
92 set complete+=k   " Scan spell dictionaries for completion in addition to standard places
93 set infercase     " adjust case of a keyword completion match
94 set nojoinspaces  " Do not insert two spaces after a '.', '?' and '!' with a join command
95 set nrformats=hex " I seldom edit octal numbers, but very often dates like 2001-02-01
96
97 " Default value 'croql' is a compromise for both natural and programming
98 " languages, but as any compromise it works good for neither natural nor
99 " programming languages. This value is good for natural texts,
100 " let ftplugins to set values suitable for programming languages.
101 set formatoptions=2t " list of flags that tell how automatic formatting works
102
103 " 15 tabs and indenting
104
105 set expandtab     " expand <Tab> to spaces in Insert mode
106 set shiftwidth=3  " number of spaces used for each step of (auto)indent
107 set smarttab      " a <Tab> in an indent inserts 'shiftwidth' spaces
108 set softtabstop=3 " number of spaces to insert for a <Tab>
109
110 set noautoindent  " Do not automatically set the indent of a new line
111
112 " 18 mapping
113
114 set timeout timeoutlen=3000 " allow timing out up to 3 seconds halfway into a mapping
115
116 " 19 reading and writing files
117 if v:version >= 703
118    set cryptmethod=blowfish " encryption method for file writing: zip or blowfish
119 endif
120
121 " 21 command line editing
122
123 set history=1000  " how many command lines are remembered
124 set suffixes+=.pyc,.pyo " list of file name extensions that have a lower priority
125 set wildignore+=*.py[co] " Ignore these patterns when completing file names
126 set wildmenu      " command-line completion shows a list of matches
127 set wildmode=longest,list:longest,full " Bash-vim completion behavior
128
129 " 22 executing external commands
130
131 if has("filterpipe")
132    set noshelltemp " Use pipes on Unix
133 endif
134
135 " 25 multi-byte characters
136
137 " Automatically detected character encodings
138 set fileencodings=ucs-bom,us-ascii,utf-8,koi8-r,cp1251,cp866,latin1
139
140 " 26 various
141
142 " ! - when included, save and restore global variables that start
143 "     with an uppercase letter, and don't contain a lowercase letter;
144 " h - disable the effect of 'hlsearch';
145 " ' - number of files for which the marks are remembered;
146 " " and < - maximum number of lines saved for a register;
147 " s - maximum size of an item in Kbytes.
148 if version < 603
149    set viminfo=!,h,'50,\"1000
150 else
151    set viminfo=!,h,'50,<1000,s10
152 endif
153
154 " c - convert viminfo to the current encoding;
155 if has("iconv")
156    set viminfo^=c
157 endif
158
159 " Removable media paths
160 if has("win32")
161    set viminfo+=ra:,rb:
162 endif
163
164 " ----------
165
166 if has("gui_running")
167    set background=light
168
169    if has("win32")
170       "set guifont=Courier_New:h18:cRUSSIAN
171       set guifont=Lucida_Console:h18:cRUSSIAN
172    else
173       set guifont=Monospace\ 16
174       set toolbar=icons,text " how to show the toolbar
175    endif
176
177    " set guicursor+=a:blinkon0 " Stop cursor blinking
178
179    " Make shift-insert work like in Xterm
180    " map <S-Insert> <MiddleMouse>
181    " map! <S-Insert> <MiddleMouse>
182
183
184    " Set nice colors
185    " Background for normal text is light grey
186    " Cursor is green
187    " Text below the last line is darker grey
188    " Status line is bright white on blue
189    highlight Normal guibg=grey90
190    highlight Cursor guibg=green guifg=NONE
191    highlight NonText guibg=grey80
192    highlight Constant guibg=grey90
193    highlight Special gui=NONE guibg=grey90
194    highlight StatusLine gui=bold guifg=white guibg=blue
195
196    " ----------
197    " From http://slobin.pp.ru/vim/_vimrc.html
198
199    " Arrows should go into wrapped lines, but not while popup menu is visible
200    imap <expr> <Down> pumvisible() ? "<Down>" : "<C-O>gj"
201    imap <expr> <Up> pumvisible() ? "<Up>" : "<C-O>gk"
202
203    " The <CR> key should select from completion menu without adding a newline
204    imap <expr> <CR> pumvisible() ? "<C-Y>" : "<CR>"
205    " ----------
206 else
207
208    if (&term =~ "linux") || ($BACKGROUND == 'DARK') || ($BACKGROUND == 'dark')
209          \ || has("win32")
210       " Background of the terminal is black or dark grey
211       set background=dark
212       highlight MoreMsg ctermfg=white
213       highlight ModeMsg ctermfg=white
214       highlight Question ctermfg=white
215    else
216       set background=light
217       highlight MoreMsg cterm=bold ctermfg=NONE
218       highlight Question cterm=bold ctermfg=NONE
219    endif
220
221    if (&term =~ "linux")
222       execute 'set t_kb=' . nr2char(127)
223    endif
224
225    if (&term =~ "rxvt") || (&term =~ "screen") || (&term =~ "term") || (&term =~ "vt100")
226       execute 'set t_kb=' . nr2char(127)
227
228       " 'autoselect' to always put selected text on the clipboard;
229       " 'unnamed' to use the * register like unnamed register '*'
230       " for all yank, delete and put operations;
231       " This allows to use mouse for copy/paste in local xterm,
232       " but prevents to save the unnamed register between sessions.
233       " set clipboard=autoselect,unnamed,exclude:cons\|linux
234
235       if has ("terminfo")
236          " set t_Co=256
237          set t_Co=16
238       else
239          set t_Co=8
240          set t_Sf="\e[3%dm"
241          set t_Sb="\e[4%dm"
242       endif
243    endif
244
245    if (&term =~ "screen")
246       set ttymouse=xterm2 " Enable mouse codes under screen/tmux
247       if empty(&t_ts)
248          " Enable window title under screen/tmux
249          let &t_ts = "\e]2;"
250          let &t_fs = "\007"
251       endif
252    endif
253 endif
254
255 highlight SpellBad term=underline cterm=NONE ctermfg=white ctermbg=red guifg=white guibg=red " gui=undercurl guisp=red
256 highlight StatusLine cterm=bold ctermfg=white ctermbg=blue gui=NONE guifg=white guibg=blue
257 highlight Visual cterm=NONE ctermfg=white ctermbg=blue gui=NONE guifg=white guibg=blue " Selection highlighting
258
259 " Multiline comments often confuse vim syntax highlighting - these maps
260 " allow to resynchronize; the first is faster, the second is more thorough
261 nmap \sc :syntax sync clear<Enter>
262 nmap \ss :syntax sync fromstart<Enter>
263
264
265 " AUTOCOMMANDS
266
267 " Enable filetype detection
268 filetype plugin indent on
269
270 runtime macros/matchit.vim
271
272 " Reread me after editing
273 autocmd BufWritePost ~/.vimrc source ~/.vimrc | syntax on
274
275 if version >= 700
276 " Save all files before running any quickfix command (grep, makeprg, etc.)
277 autocmd QuickFixCmdPre * wall
278 endif
279
280 " Syntax highlighting
281 autocmd BufReadPost * syntax on
282
283
284 " Restore last known cursor position
285 function! RestorePosition()
286    if exists('b:position_restored')
287       return
288    endif
289
290    if line("'\"") > 0
291       call cursor(line("'\""), col("'\""))
292    endif
293    let b:position_restored = 1
294 endfunction
295
296 " When editing a file, always jump to the last cursor position (if saved)
297 autocmd BufReadPost * call RestorePosition()
298
299
300 function! SetupEncoding(encoding)
301    if !has("iconv") || exists('b:encoding_set') || strlen(a:encoding) == 0
302       return
303    endif
304
305    call RestorePosition()
306    let b:encoding_set = 1
307    execute "edit ++enc=" . a:encoding
308 endfunction
309
310
311 " http://lwn.net/Articles/226514/
312
313 augroup gpg
314 " Remove ALL autocommands for the current group.
315 autocmd!
316 autocmd BufReadPre,FileReadPre *.gpg set viminfo=
317 autocmd BufReadPre,FileReadPre *.gpg setlocal noswapfile
318 autocmd BufReadPost *.gpg :%!gpg -q -d
319 autocmd BufReadPost *.gpg | redraw
320 autocmd BufWritePre *.gpg :%!gpg --default-recipient-self -q -e -a
321 autocmd BufWritePost *.gpg u
322 autocmd VimLeave *.gpg :!clear
323 " For OpenSSL:
324 " BufReadPost: use "openssl bf -d -a"
325 " BufWritePre: use "openssl bf -salt -a"
326 augroup END
327
328
329 function! SetWrap()
330    setlocal wrap
331    map <Up> gk
332    imap <Up> <C-O>gk
333    map <Down> gj
334    imap <Down> <C-O>gj
335    let b:wrap = 1
336 endfunction
337
338 function! SetNoWrap()
339    setlocal nowrap
340    map <Up> k
341    map <Down> j
342    let b:wrap = 0
343 endfunction
344
345 command! SetWrap call SetWrap()
346 command! SetNoWrap call SetNoWrap()
347
348 " b:wrap can be set by an ftplugin
349 autocmd BufReadPost * if !exists("b:wrap") | call SetWrap() | endif
350
351
352 " MAPPINGS
353
354 " Do not unindent #-comment
355 inoremap # X<C-H>#
356
357 " map <C-A> <Home>
358 " map <C-E> <End>
359 " map <C-Z> :shell<CR>
360
361
362 if version >= 700
363 " WEB BROWSERS
364
365 let s:URL_re="\\v(((https?|ftp|gopher|telnet)://|(mailto|file|news|about|ed2k|irc|sip|magnet):)[^' \t<>\"]+|(www|web|w3)[a-z0-9_-]*\\.[a-z0-9._-]+\\.[^' \t<>\"]+)[a-z0-9/]\\c"
366
367 function! ExtractURL()
368    let line = getline('.')
369    let parts = split(line, s:URL_re . '\zs')
370
371    if len(parts) == 0
372       throw 'ExtractURLCannotFindURL' " No URL found
373    endif
374
375    let length = 0
376    let column = col('.')
377
378    for p in parts
379       let save_length = length
380       let length += len(p)
381       if length >= column
382          break
383       endif
384    endfor
385
386    let pos = match(p, s:URL_re)
387    if pos == -1
388       throw 'ExtractURLCannotFindURL' " No URL found
389    endif
390
391    if save_length + pos >= column " cursor left of the URL
392       throw 'ExtractURLCannotFindURL'
393    endif
394
395    return strpart(p, pos)
396 endfunction
397
398 function! EscapeURL(url)
399    let url = substitute(a:url, ' ', '%20', 'g')
400    return escape(url, '!#$%')
401 endfunction
402
403 function! OpenURL(url, newwin)
404    execute "!webbrowser " . a:newwin . " '" . EscapeURL(a:url) . "'"
405 endfunction
406
407 function! ExtractOpenURL(newwin)
408    try
409       let url = ExtractURL()
410    catch /^ExtractURLCannotFindURL$/
411       echoerr 'No URL found under cursor'
412       return
413    endtry
414
415    call OpenURL(url, a:newwin)
416 endfunction
417
418 function! EncodeOpenURL(url, newwin)
419    execute "!webbrowser-encode-url " . a:newwin . " '" . EscapeURL(a:url) . "'"
420 endfunction
421
422
423 " Send current link to a browser
424 nmap \b :call ExtractOpenURL('')<CR>
425 nmap \w :call ExtractOpenURL('-n')<CR>
426 nmap \t :call ExtractOpenURL('-t')<CR>
427 " Send visual block to a browser
428 vmap \b ""y:call OpenURL('<C-R>"', '')<CR>
429 vmap \w ""y:call OpenURL('<C-R>"', '-n')<CR>
430 vmap \t ""y:call OpenURL('<C-R>"', '-t')<CR>
431 " Encode and send visual block to a browser
432 vmap \B ""y:call EncodeOpenURL('<C-R>"', '')<CR>
433 vmap \W ""y:call EncodeOpenURL('<C-R>"', '-n')<CR>
434 vmap \T ""y:call EncodeOpenURL('<C-R>"', '-t')<CR>
435 " Send current file's name to a browser
436 nmap \B :call EncodeOpenURL('file:' . expand("%:p"), '')<CR>
437 nmap \W :call EncodeOpenURL('file:' . expand("%:p"), '-n')<CR>
438 nmap \T :call EncodeOpenURL('file:' . expand("%:p"), '-t')<CR>
439
440 endif " version >= 700
441
442
443 " SPELLING
444
445 if has("spell") " Works in 7.0+
446    " Use builtin spellchecker
447    nmap \sv :syntax off <BAR> setlocal spell<CR>
448    " Clear
449    nmap \sn :syntax on <BAR> setlocal nospell<CR>
450 endif
451
452
453 " Russian letters mapped in normal mode
454 "if has("keymap")
455 "   set keymap=russian-jcuken
456 "endif
457
458 if has("langmap")
459    if v:version >= 702
460       " langmap in utf-8 mode requires at least Vim 7.2.109
461       scriptencoding utf-8
462       set langmap=ё`Ё~йqцwуeкrеtнyгuшiщoзpх[ъ]фaыsвdаfпgрhоjлkдlж\\;э'
463                  \яzчxсcмvиbтnьmб\\,ю.ЙQЦWУEКRЕTНYГUШIЩOЗPХ{Ъ}
464                  \ФAЫSВDАFПGРHОJЛKДLЖ:Э\\"ЯZЧXСCМVИBТNЬMБ<Ю>
465
466    elseif &encoding != 'utf-8'
467       scriptencoding koi8-r
468       set langmap=ё`Ё~йqцwуeкrеtнyгuшiщoзpх[ъ]фaыsвdаfпgрhоjлkдlж\\;э'
469                  \яzчxсcмvиbтnьmб\\,ю.ЙQЦWУEКRЕTНYГUШIЩOЗPХ{Ъ}
470                  \ФAЫSВDАFПGРHОJЛKДLЖ:Э\\"ЯZЧXСCМVИBТNЬMБ<Ю>
471    endif
472
473    scriptencoding us-ascii
474 endif
475
476
477 if version >= 700
478 function! W()
479    " let encodings=filter(split(&fileencodings, ','), 'v:val != "ucs-bom"')
480    let encodings = ['us-ascii']
481    if $LC_CTYPE =~ 'UTF-8' " UTF-8 or en_US.UTF-8 or ru_RU.UTF-8 or such
482       let encodings += ['utf-8']
483    elseif $LC_CTYPE == 'ru_RU.KOI8-R'
484       let encodings += ['koi8-r', 'utf-8']
485    elseif v:lc_time == 'Russian_Russia.1251'
486       let encodings += ['cp1251', 'utf-8']
487    endif
488
489    for e in encodings
490       try
491          execute 'set fileencoding=' . e
492          w
493          break
494       catch /E513: write error, conversion failed/
495          continue
496       endtry
497    endfor
498
499    if &modified
500       throw '"' . expand('%') . '" E513: write error, conversion failed; tried ' . join(encodings, ',')
501    elseif has("spell")
502       call SetupSpell()
503    endif
504 endfunction
505
506 command! W call W()
507 endif
508
509
510 function! SlowTerm()
511    set laststatus=1
512    set noruler
513    set shortmess=aoOtT
514    set noshowcmd
515    set scrolljump=5 " The minimal number of lines to scroll vertically when the cursor gets of the screen
516    set sidescroll=5
517    set nottyfast
518    set notitle
519    set timeoutlen=5000
520    set nowildmenu
521    set wildmode=list:longest
522    set viminfo=!,h,'10,<100,s5
523    syntax off
524    highlight NonText cterm=NONE ctermfg=NONE
525 endfunction
526
527 if exists("$SLOWTERM")
528    call SlowTerm()
529 endif
530
531
532 " ----------
533 " From http://slobin.pp.ru/vim/_vimrc.html
534
535 " These options will be kept between editing sessions
536 " let options = []
537
538 " Called automagically after .viminfo and plugins are loaded, sets
539 " miscellaneous options from persistent global variables
540 " function! VimEnter()
541   " for optname in g:options
542   "   let varname = "g:OPT_" . toupper(optname)
543   "   if exists(varname)
544   "     execute "let &" . optname . " = " . varname
545   "   endif
546   " endfor
547
548   " if has("gui_running") && exists("g:WINPOSX") && exists("g:WINPOSY")
549   "   execute "winpos" g:WINPOSX g:WINPOSY
550   " endif
551 " endfunction
552
553 " Called automagically before .viminfo is saved, saves miscellaneous
554 " options into persistent global variables
555 " function! VimLeavePre()
556   " call filter(g:, 'v:key !~# "^OPT_"')
557   " for optname in g:options
558   "   let varname = "g:OPT_" . toupper(optname)
559   "   execute "let " . varname . " = &g:" . optname
560   " endfor
561
562   " if has("gui_running")
563   "   let g:WINPOSX = getwinposx()
564   "   let g:WINPOSY = getwinposy()
565   " endif
566 " endfunction
567
568 " autocmd VimEnter * call VimEnter()
569 " autocmd VimLeavePre * call VimLeavePre()
570
571
572 " Called automagically after every buffer read, enables fileencoding
573 " setting from modeline (see Tip #911: http://vim.wikia.com/wiki/VimTip911)
574 function! AutoEncoding()
575   if &modified && &fileencoding != ""
576     call SetupEncoding(&fileencoding)
577   else
578     redraw
579   endif
580   autocmd! auto-encoding
581   augroup! auto-encoding
582 endfunction
583
584 augroup auto-encoding
585 autocmd!
586 autocmd BufWinEnter * call AutoEncoding()
587 augroup END
588
589
590 let CONVERT=1
591
592 " Value of a character under cursor; better than standard '0x%02B (%b)'
593 function! HexDec()
594   let char = matchstr(getline("."), ".", col(".") - 1)
595   if g:CONVERT
596     let char = iconv(char, &encoding, &fileencoding)
597     let format = "0x%02X <%d>"
598   else
599     let format = "0x%02X (%d)"
600   endif
601   let char = char2nr(char)
602   return printf(format, char, char)
603 endfunction
604
605
606 if has("iconv")
607    " Helper function for :DecodeQP and :DecodeURL commands
608    function! DecodeHex(arg)
609      return iconv(printf("%c", str2nr(submatch(1), 16)), a:arg, &encoding)
610    endfunction
611
612    " Custom completion for encoding names
613    function! EncList(ArgLead, CmdLine, CursorPos)
614      return filter(split(&fileencodings, ','),
615                  \ "strpart(v:val, 0, strlen(a:ArgLead)) == a:ArgLead")
616    endfunction
617
618    if version >= 700
619    " Command for decoding qp-encoded text
620    command! -bar -nargs=? -range -complete=customlist,EncList DecodeQP
621           \ <line1>,<line2>s/=\(\x\x\|\n\)/\=DecodeHex(<q-args>)/eg
622
623    " Command for decoding url-encoded text
624    command! -bar -nargs=? -range -complete=customlist,EncList DecodeURL
625           \ <line1>,<line2>s/%\(\x\x\)/\=DecodeHex(<q-args>)/eg
626    endif
627 endif
628
629
630 if has("spell")
631    function! SetupSpell()
632       if &fileencoding =~ 'ascii'
633          setlocal spelllang=en spellfile=~/.vim/spell/en.ascii.add
634       elseif &fileencoding == 'koi8-r'
635          setlocal spelllang=en,ru spellfile=~/.vim/spell/en.ascii.add,~/.vim/spell/ru.koi8-r.add
636       elseif &fileencoding == 'utf-8'
637          setlocal spelllang=en,ru spellfile=~/.vim/spell/en.ascii.add,~/.vim/spell/ru.utf-8.add
638       else
639          setlocal spelllang= spellfile=
640       endif
641    endfunction
642    autocmd BufReadPost * call SetupSpell()
643 endif
644
645
646 function! SyntaxName()
647   echomsg synIDattr(synID(line("."), col("."), 1), "name")
648 endfunction
649
650
651 if has("python")
652
653 python << END_OF_PYTHON
654
655 import sys, rlcompleter, unicodedata, vim
656 from itertools import *
657 vim_complete = rlcompleter.Completer().complete
658
659 def vim_comp_list():
660   """Implementation of CompList() function"""
661   arglead = vim.eval("a:ArgLead")
662   fence = int(vim.eval("match(a:ArgLead, '\(\w\|\.\)*$')"))
663   left, right = arglead[:fence], arglead[fence:]
664   try:
665     completions = (vim_complete(right, i) for i in count())
666     candidates = list(takewhile(bool, completions))
667   except NameError:
668     candidates = []
669   suggestions = [left + x for x in candidates]
670   vim.command("return " + repr(suggestions))
671
672 def vim_calc(command):
673   """Implementation of :Calc command"""
674   global _
675   try:
676     result = eval(command)
677   except SyntaxError:
678     exec command in globals()
679   else:
680     if result != None:
681       print result
682       _ = result
683       xx = ''.join('\\x%02x' % ord(x) for x in str(_))
684       vim.command('let @" = "%s"' % xx)
685
686 def vim_pydo(command):
687   """Implementation of :Pydo command"""
688   codeobj = compile(command, "command", "eval")
689   line1 = vim.current.range.start
690   line2 = vim.current.range.end
691   delta = 0
692   for numz in range(line1, line2+1):
693     line = vim.current.buffer[numz-delta]
694     uline = unicode(line, vim.eval('&fileencoding'))
695     num = numz + 1
696     words = line.split()
697     result = eval(codeobj, globals(), locals())
698     if result is None or result is False:
699       del vim.current.buffer[numz-delta]
700       delta += 1
701       continue
702     if isinstance(result, list) or isinstance(result, tuple):
703       result = " ".join(map(str, result))
704     else:
705       result = str(result)
706     vim.current.buffer[numz-delta] = result
707
708 def vim_unicode_name():
709   try:
710     char = vim.eval("matchstr(getline('.'), '.', col('.') - 1)")
711     print map(unicodedata.name, char.decode(vim.eval("&encoding")))
712   except (AttributeError, ValueError), target:
713     print "%s: %s" % (target.__class__.__name__, target.message)
714
715 END_OF_PYTHON
716
717 " Custom completion for python expressions
718 function! CompList(ArgLead, CmdLine, CursorPos)
719   python vim_comp_list()
720 endfunction
721
722 " Python command line calculator
723 command! -nargs=+ -range -complete=customlist,CompList Calc
724        \ <line1>,<line2> python vim_calc(<q-args>)
725
726 " Python text range filter
727 command! -nargs=+ -range -complete=customlist,CompList Pydo
728        \ <line1>,<line2> python vim_pydo(<q-args>)
729
730 " Display unicode name for the character under cursor
731 command! Uname python vim_unicode_name()
732 command! UName call Uname()
733
734 endif
735 " ----------
736
737 " This has to go to the very end of ~/.vimrc to allow reading the .vimrc
738 set secure        " safer working with script files in the current directory