> > On 2009-02-09, Matt Wozniski wrote:
> >
> >> There's no easy way to get all options, afaik.
> >
> >    :set all
>
> I meant from vimscript.  Sure, between  :set all  and  :set termcap
> you can get a list of all the options, and with :redir you can get
> that into a string, but parsing that string would be incredibly
> difficult without knowing all of the option names ahead of time - and,
> if you knew that, you could just query them each directly.

> ~Matt

How about something like this? (tested) :)

function! GetAllSettings()
   silent let output = s:getem()
   let all = {}
   let lastline = ""
   for line in split(output, '\n')
      if line =~ "^---"
         continue
      endif
      if line > lastline
         let items = split(line)
         for item in items
            let list = split(item, "=")
            let i = list[0]
            if len(list) == 1
               if i =~ "^no"
                  let all[i[2:-1]] = 0
               else
                  let all[i] = 1
               endif
            elseif len(list) == 2
               let all[i] = list[1]
            endif
         endfor
         let lastline = substitute(line, "no", "  ", "g")
      else
         let list = split(line, "=")
         let val = matchstr(list[0], '\w\+')
         let all[val] = list[1]

         let list[0] = val

         let lastline = "zzzz"
      endif
   endfor
   for k in sort(keys(all))
      echom "all[".k."] = ".all[k]
   endfor
endfunction

function! s:getem()
   redir => allsettings
   set all
   redir END
   return allsettings
endfunction

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui