I don't want to do this manually, and I'm sure there is a way for vim to do it. I probably am not googling the correct question to find the result I want, but here is what I want to do. I have this block of code:

    // Move the topSideLeft point to the topLeft corner
    topSideLeft->left = new MapChunk;
    topSideLeft->left->right = topSideLeft;
    topSideLeft->left->bottom = topSideLeft->bottom->left;
    topSideLeft->bottom->left->top = topSideLeft->left;
    // Move the topSideRight point to the topRight corner
    topSideRight->right = new MapChunk;
    topSideRight->right->left = topSideRight;
    topSideRight->right->bottom = topSideRight->bottom->right;
    topSideRight->bottom->right = topSideRight->right;

What I want to do is have all the text that says bottom be top, and all the text that says top be bottom.


    // Move the bottomSideLeft point to the bottomLeft corner
    bottomSideLeft->left = new MapChunk;
    bottomSideLeft->left->right = bottomSideLeft;
    bottomSideLeft->left->top = bottomSideLeft->top->left;
    bottomSideLeft->top->left->bottom = topSideLeft->left;
    // Move the bottomSideRight point to the bottomRight corner
    bottomSideRight->right = new MapChunk;
    bottomSideRight->right->left = topSideRight;
    bottomSideRight->right->top = bottomSideRight->top->right;
    bottomSideRight->top->right = bottomSideRight->right;

It would be something like: s/top/bottom/g & s/bottom/top/g, but like at the same time so it replaces it with each other rather than just replacing either top or bottom.


1 Answer 1


Duplicate of Can I replace two distinct old strings with two distinct new strings using a single :s command?

Sometimes people ask questions in such different ways that it makes it near impossible for the search engine to figure out the correct stack overflow link to send you to.


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