Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 0 down vote accepted

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

:redir => output
:filetype
: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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.