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.
:h 'paste'
answer much of this? It lists all the settings that disabled/reset.smartindent
, norautoindent
. 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.