How do I un-join(?) or add trailing whitespace with indentation?

With this code,,,

import { amethod, methodb, methodc } from '../../utils/mockData';

how do you make this

import {
} from '../../utils/mockData';

I mean how can I do it fast?

What I do is to

  1. go to the first method.
  2. press Enter
  3. go to the end of the method..
  4. press Enter...
  5. go to the second method. 6.... ...

It's so slow with VIM. Can we do this fast in VIM?

  • 1
    Use f<space>. to jump to the spaces. Continue jumping using ;. When you are on a space that you would like to be a linebreak, press r<Enter>. Continue – Christian Brabandt Oct 14 '20 at 6:58
  • WOWOWOWOWOWOWOWOWOOWOWW that's for the trick!!!!!!!!! super nice – hellofanengineer Oct 14 '20 at 7:04
  • It worked... I continue to jump and make a line break – hellofanengineer Oct 14 '20 at 7:04
  • You can also use . to repeat the last change, and use it after the first r<Enter> -- so it becomes ;. for the subsequent changes. – Sakari Cajanus Oct 14 '20 at 9:53

Christian Brabandt has a good answer in the comments, and is similar to what I do in other situations: f<Space>, r<Enter>, then use ;. to continue.

With tpope’s surround plugin, I can do cS{{ and get the same effect.

It’s possible the splitjoin plugin can do something similar.

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.