How to autocomplete std:: + intellicode doesn't seem to work?

empleat 131 Reputation points
2021-04-07T08:44:59.317+00:00

I am using windows 10 VS community 19, how do I autocomplete std:: please? I have installed intellisense and intellicode. Also intellicode doesn't show any starred words at top of a list. I have enabled c++ base model, but otherwise there was nothing, I even googled it and what they had there - I didn't...

Developer technologies Visual Studio Other
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Viorel 122.5K Reputation points
    2021-04-07T09:13:00.59+00:00

    Did you include the header files? For example, if you want to use std::string, then add the #include <string> directive.

    Which kind of project and code did you try?

    0 comments No comments

  2. empleat 131 Reputation points
    2021-04-07T19:04:37.937+00:00

    Console. I want it use for cout and cin, endl mostly for now. So when I write like: cout, it would autocomplete to std::cout. Because include namespaces std; is a bad practice I read.

    0 comments No comments

  3. Dylan Zhu-MSFT 6,426 Reputation points
    2021-04-08T03:10:27.863+00:00

    Hi empleat,

    As far as I know, we cannot autocomplete namespace through function name in c++ editor.

    After some tests, I found code snippet, maybe it can meet your requirement:

    1. Create a text file with .snippet
      85582-image.png
    2. Type these contexts in it
      85581-image.png
    3. Move it to C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\Snippets\1033\Visual C++
    4. Type 's' then press 'Tab' key, and it will auto-input std:: into editor

    Best Regards, Dylan

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our * *documentation* to enable e-mail notifications if you want to receive the related email notification for this thread.**

    0 comments No comments

  4. empleat 131 Reputation points
    2021-04-09T12:30:41.18+00:00

    You kidding right, couldn't you just copy paste them, instead of making a picture?

    It is kinda weird, someone had to ask already this question. VS is like most complex IDE no, strange that there would be nothing better!

    Isn't there like some addon which could do this BTW?

    Also what if there was like variable named s, or something and I would want to do a indentation?


  5. empleat 131 Reputation points
    2021-06-28T17:25:47.837+00:00

    I found easy solution as I Am learning: https://www.learncpp.com/cpp-tutorial/using-declarations-and-using-directives/

    Apparently using std::cout; saves you from writing std:: each time and it is generally considered safe.

    How the hell no one told me that?!

    And as we all know - using namespace std:: is a bad idea, because if something changes in future C++ versions etc. it can easily mess a whole program!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.