From e0aae75865479d6de0a9e129a205b20e469abafc Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Thu, 17 Dec 2015 21:31:57 +0100 Subject: [PATCH] Place before namespace if no include found In case you use this in header files, it would be better to look for a namespace declaration then putting it on top, where the guard header should be. --- plugin/cpp_auto_include.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/cpp_auto_include.vim b/plugin/cpp_auto_include.vim index 8252e58..a760458 100644 --- a/plugin/cpp_auto_include.vim +++ b/plugin/cpp_auto_include.vim @@ -122,6 +122,8 @@ module CppAutoInclude VIM::lines.each_with_index do |l, i| if l =~ /^\s*#\s*include/ includes << [l, i+1] + elsif l =~ /^\s*namespace/ and includes.length == 1 + includes[0][-1] = i else content << l.gsub(/\/\/[^"]*(?:"[^"']*"[^"]*)*$/,'') << "\n" end