Detect usage of std:: and avoid using namespace#3
Conversation
|
To be honest, the current change makes the code harder to read. Let's do this instead: If diff --git a/cpp_auto_include.vim b/cpp_auto_include.vim
index 6bcfa34..e593250 100644
--- a/cpp_auto_include.vim
+++ b/cpp_auto_include.vim
@@ -111,6 +111,7 @@ module CppAutoInclude
]
USING_STD = 'using namespace std;'
+ USING_STD_REGEX = /using namespace std;|std::/
# do nothing if lines.count > LINES_THRESHOLD
LINES_THRESHOLD = 1000
@@ -164,7 +165,7 @@ module CppAutoInclude
end
# add / remove 'using namespace std'
- has_std = content[USING_STD]
+ has_std = content[USING_STD_REGEX]
if use_std && !has_std && !includes.empty?
VIM::append(includes.last.last+1, USING_STD) |
|
Ok, i haven't thought about that Solution. Well to be honest I haven't really taken care of the variable names. Thanks. Am 17.12.2015 um 22:31 schrieb Jun Wu <notifications@github.com mailto:notifications@github.com >: To be honest, the current change make the code hard to read. $1 is discouraged in Ruby and names like regexp and rex confuses people. Let's do this instead: If std:: is found, do not add using namespace std; diff --git a/cpp_auto_include.vim b/cpp_auto_include.vim USING_STD = 'using namespace std;'
do nothing if lines.count > LINES_THRESHOLDLINES_THRESHOLD = 1000
— |
f52997f to
54efbe5
Compare
|
Fixed it |
E.g. goole code style tells you not to do so.