" =========================================================================== " File: basics.vim " Author: Stefan Liebl (S.Liebl@gmx.de) " Description: some usefull standard functions " " Must be first file in this directory " =========================================================================== if (v:version < 700) echo 'update your vim' endif " ---------------- " useful functions " ---------------- function GetLine() let line_nr = line('.') let line = getline(line_nr) return line endfunction function PrintLine(text) let line_nr = line('.') let line = GetLine() echo a:text . line_nr . ' ' . line endfunction command -nargs=1 EchoDebug call EchoDebug() function EchoDebug(text) if exists('g:debug') if (g:debug > 0) execute 'echo "' . a:text . '"' endif endif endfunction "command -nargs=1 PathNormpath call PathNormpath('') "function PathNormpath(string) " if (v:version > 602) " try "python < 602) try python < 602) try let expression = substitute(a:expression, '\.\d\+', '', '') python < 602) try let expression = substitute(a:expression, 'L', '', '') python <\)', '\1\2', '') "echo 'result:'.result.':'. a:bits digits endif catch /^Vim\%((\a\+)\)\=:E370/ " python not available throw 'ToHex needs python' let result = a:expression endtry else echoerr 'ToHex needs python' let result = a:expression endif return result endfunction " get date function GetDate() let l:full_date = system('date /T') let l:day = matchstr(l:full_date,'\a\+') let l:date = matchstr(l:full_date,'[0-9.]\+') return l:date endfunction "function Wait(seconds) " let starttime = localtime() " while ((localtime() - starttime) < a:seconds) " endwhile "endfunction function ReversePatch() silent execute '!patch -R -o' v:fname_out v:fname_in '<' v:fname_diff endfunction EchoDebug 'loaded _stefan.vim'