0

Let's start form this faulty C++ source file

#include <vector>
int main() {
    std::vector<std::vector<int>> v{
            1,2},
            9,3},
            4,2}
    };
}

which is a legit transitory state if you've just copied those 6 numbers from a space-separated text file with two columns.

The last step is to add opening braces on the three lines, so you might put the cursor on the 1, and then go Ctrl-v2jI{Escape. Doing so, however, you end up with this,

#include <vector>
int main() {
    std::vector<std::vector<int>> v{
        {1,2}
            1,1}
            1,2}
    };
}

because the auto indentation pulled the line where the cursor initially is to the left (for whatever reason will be explained in this previous question), i.e. it deleted text, thus breaking out of the block visual mode.

However, if that key sequence is used after :set paste, then the edit is as desired.

I'd like to know how these things play together.

3
  • Doesn't :h 'paste' answer much of this? It lists all the settings that disabled/reset.
    – B Layer
    Nov 10 '20 at 16:49
  • Yes, I think it does, but I'm still figuring out which ones affect the behavior. It's not smartindent, nor autoindent. I'll post a self answer if I don't get one, but I wouldn't delete this question, since it's taking more than just a look at the help.
    – Enlico
    Nov 10 '20 at 16:58
  • 1
    It takes a lot more than that for a question to be deleted.
    – B Layer
    Nov 10 '20 at 17:56
0

It looks like the reason why :set paste solves the issue is that, among other things, it deactivates cindent, and cindent makes use of cinkeys's default value, which triggers the reindentation if one types { (or other characters) at the beginning of the line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.