Vim: Captue 'filetype command' state to variable?

1

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?

E.Beach

Posted 2012-06-22T15:09:16.753

Reputation: 137

Answers

0

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\+\)')

Raimondi

Posted 2012-06-22T15:09:16.753

Reputation: 183

Should that be [matchstr, detection, plugin, indent; _]? According to the help, the matched string is the first parameter. – E.Beach – 2012-06-22T17:54:08.723

Correct. I've updated the code. I always make that mistake with matchlist() and I'm left wondering what's wrong... – Raimondi – 2012-06-22T20:31:29.077