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