How can I debug problems in VimL?

I would like to know more about debugging in vim. What features does vim have that can help me diagnose a problem that I might have?

I would like to know:

  • How can I diagnose a problem with my .vimrcand other configuration files?
  • What are some strategies for debugging a script in VimL?
+3
source share
3 answers

How can I diagnose a problem with .vimrc and other configuration files?

- vim, , , . - , . vim, .vimrc.

vim 'option', . :verbose, .

:verbose set nocompatible?
nocompatible
     Last set from ~/.vimrc

vim - ,

vim -N -u NONE

cleanvim .bashrc . -u NONE . -N vim nocompatible, . NORC vimrc. , - vundle vimrc, .

, pathogen vundle, ; .vimrc, . , , .vim --noplugin.

, , . .

.vimrc, . finish .vimrc. , script . , .vimrc .

script VimL?

Vim :h debug-scripts. vim debug mode, . . ...

" set a breakpoint on the function MyCoolFunc
:breakadd func MyCoolFunc

" set a breakpoint on line 43 of your .vimrc
:breakadd file 43 .vimrc

" set a breakpoint at this location
:breakadd here

, , , . , vim -D . . , , :MyCommand. :debug MyCommand.

, vim. , , echo, . verbose . . :h 'verbose' .

+4

vimL:

  • Vim.
  • :Runtime , .
  • :Disarm {file}: , , autocmds
  • :Time {command}: profilling
  • :Verbose {command}: :verbose, .

, Vim (: ), :RestartVim .

+3

vimL 2 :

  • BreakPts

    Set / view Vim breakpoints and view functions visually

  • Decho

    Improved echo functionality suitable for debugging scripts

I also use this to quickly source selected vimL strings:

fu! SourceRange() range
  let tmpsofile = tempname()
  call writefile(getline(a:firstline, a:lastline), l:tmpsofile)
  execute "source " . l:tmpsofile
  call delete(l:tmpsofile)
  let n = a:lastline - a:firstline + 1
  echo 'Sourced ' . n . ' line' . (n > 1 ? 's' : '')
endf
com! -range Source <line1>,<line2>call SourceRange()

nn gs m`:Source<cr>``
vn gs m`:Source<cr>``
+1
source

All Articles