Skip to content

Commit 8600479

Browse files
committed
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.
1 parent 6946d4a commit 8600479

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

plugin/cpp_auto_include.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ module CppAutoInclude
122122
VIM::lines.each_with_index do |l, i|
123123
if l =~ /^\s*#\s*include/
124124
includes << [l, i+1]
125+
elsif l =~ /^\s*namespace/ and includes.length == 1
126+
includes << ['', i]
125127
else
126128
content << l.gsub(/\/\/[^"]*(?:"[^"']*"[^"]*)*$/,'') << "\n"
127129
end

0 commit comments

Comments
 (0)