From e3731db59b8cb4a918120b50a7719413cee16fd4 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 28 May 2014 16:18:21 +0200 Subject: append a 'vim: ft=' line you can specify how vim shall handle the generated output by default, it will be considered as a vimrc file --- VimperatorrcBuilder.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'VimperatorrcBuilder.py') diff --git a/VimperatorrcBuilder.py b/VimperatorrcBuilder.py index a73f329..d918276 100644 --- a/VimperatorrcBuilder.py +++ b/VimperatorrcBuilder.py @@ -32,6 +32,8 @@ class VimperatorrcBuilder(): '': '', } + vim_filetype = 'vim' + def __init__(self): pass @@ -50,6 +52,14 @@ class VimperatorrcBuilder(): self.default_engine = engine + def append_vim_filetype(self, filetype='vim'): + """ Set how vim shall interpret the generated file """ + append_vim_filetype = filetype + + def disable_vim_filetype(self): + """ Prevent the output of a vim: line """ + append_vim_filetype = None + def get_output(self): ''' Return a string containing the full output to redirect ''' @@ -74,5 +84,9 @@ class VimperatorrcBuilder(): output += 'cnoremap ' + key + ' ' + self.cli_bindings[key] + '\n' output += 'inoremap ' + key + ' ' + self.cli_bindings[key] + '\n' + if self.vim_filetype is not None: + # XXX dirty hack to avoid vim interpretation of the following line + output += '\n" vim' + ': set ft=' + self.vim_filetype + ':\n' + return output -- cgit v1.2.3