Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For vim users that use a bundle manager the docs typically say to use filetype off during init.

Is there a way to capture the current filetype command state to a variable so that I can restore it after the filetype off command and the bundle manager's init code has executed?

share|improve this question
up vote 0 down vote accepted

You can use :redir to capture the output of :filetype:

:redir => output
:redir END

Then get the values with:

let [matchstr, detection, plugin, indent; _] = matchlist(output, 'detection:\(\S\+\)\s\+plugin:\(\S\+\)\s\+indent:\(\S\+\)')
share|improve this answer
Should that be [matchstr, detection, plugin, indent; _]? According to the help, the matched string is the first parameter. – E.Beach Jun 22 '12 at 17:54
Correct. I've updated the code. I always make that mistake with matchlist() and I'm left wondering what's wrong... – Raimondi Jun 22 '12 at 20:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .