vim: extend PrependSTLNamespace()
authorStefan Huber <shuber@sthu.org>
Sat, 12 Oct 2013 18:13:24 +0000 (20:13 +0200)
committerStefan Huber <shuber@sthu.org>
Sat, 12 Oct 2013 18:13:24 +0000 (20:13 +0200)
dotfiles/vim/.vimrc

index 7a05e1d5250798c9e3d6c6457632be1c28112158..8c716d410c85344ece65201c3fee7c818bb2d6e4 100644 (file)
@@ -130,25 +130,30 @@ function PrependCppNamespaceToIdent(ns, id)
     "                           |/* id */
     "                           |::id
     "                           |/**/ ::id
+       "                           |#include <id>
     "
     " In order to not match '* id' it is assumed that multi-line comment lines
     " in the middle begin with a star.
 
-    " If // and /* and ^* and :: is not prepend:
-    execute ':%s_\(\(\/\/\|\/\*\|^\s*\*[^/]\).*\|::\)\@<!\<' . a:id . '\>_' . a:ns . '::' . a:id . '_ge'
-    " If // and :: is not prepend, but */ is, and no further /* or // are found
-    execute ':%s_\(\/\/.*\)\@<!\*\/\(\/[^\/\*]\|[^\/]\)*\zs\(::\)\@<!\<' . a:id . '\>_' . a:ns . '::' . a:id . '_ge'
+    " If #include and // and /* and ^* and :: is not prepend:
+    execute ':%s_\(\(#include\|\/\/\|\/\*\|^\s*\*[^/]\).*\|::\)\@<!\<' . a:id . '\>_' . a:ns . '::' . a:id . '_ge'
+    " If #include and // and :: is not prepend, but */ is, and no further /* or // are found
+    execute ':%s_\(\(#include\|\/\/\).*\)\@<!\*\/\(\/[^\/\*]\|[^\/]\)*\zs\(::\)\@<!\<' . a:id . '\>_' . a:ns . '::' . a:id . '_ge'
 
 endfunction
 
 "Prepend STL namespace 'std::' to several identifiers
 function PrependSTLNamespace()
+       " This list of identifier is not complete, but adding all of them is too
+       " much. We rather like to add identifieres that are 'typical' for C++.
+       " Others, like 'move' are likely to not be C++ specific. In this cases the
+       " user is asked to call PrependCppNamespaceToIdent by hand.
     let id = []
     let id = id +['cin', 'cout', 'cerr', 'endl']
     let id = id +['swap', 'sort', 'max', 'min']
     let id = id +['vector', 'deque', 'list', 'map', 'multimap', 'set']
     let id = id +['queue', 'stack', 'priority_queue']
-    let id = id +['ostream', 'istream']
+    let id = id +['ostream', 'istream', 'sstream']
     let id = id +['pair', 'string']
     let id = ['map']