Reputation: 4508
What is the quickest way to move curly braces to be on the same line?
from this:
const value = {
input: 123
}
to this:
const value = { input: 123 }
The way I do it is by using Visual with a combination of hjkl.
Bonus: How can I achieve the edits but the other way around?
Upvotes: 2
Views: 179
Reputation:
For a more automated way of transforming code in both directions, consider my "splitjoin" plugin: https://github.com/andrewradev/splitjoin.vim
Being a single mapping, it would, technically, be the quickest way :)
Upvotes: 1
Reputation: 406
Put cursor at first line (const...
) and then press J repeatedly until all the code is on one line.
If you haven't bound Caps lock to anything else, you can press it before to avoid holding Shift
Upvotes: 3
Reputation: 1306
{
.Note: the behavior may break if unpaired {
or }
exists in comment/string/etc.
Upvotes: 6