t9md / atom-vim-mode-plus

vim-mode improved
https://atom.io/packages/vim-mode-plus
MIT License
1.4k stars 111 forks source link

Feature Request: Transform object literal from single to multi line #1119

Closed bennypowers closed 5 years ago

bennypowers commented 5 years ago

Hello! I ❤️ vmp. thank you so much for publishing it.

I often find myself transforming snippets like this:

const {
  hasTooltipContent,
  icon,
  originalFill,
  position,
  size,
  tooltip,
} = this;

to this:

const { hasTooltipContent, icon, originalFill, position, size, tooltip } = this;

and vice-versa.

I'd like it if there was a general operation to toggle this sort of thing.

Contrast current work flow: to collapse object: shift-J as many times as needed to expand object: f space l s return as many times as needed, then manually adjusting indentation.

with a potential workflow:

g z i {

for "toggle collapse inner object".

Thank you for considering this feature.

Checklist

t9md commented 5 years ago

I understand your background. However, vmp currently does not provide the exact feature you want.

Here is how we can do in your scenario with the current vmp feature..

For multi-line to a single line

Select area, then remove "\n" by J, then let prettier format to remove extra , or manually remove it.

For single-line to multi-line

Use split-arguments operator. Keystrokes should be g , i {.(mine is g , ; since I use shorthand keymap which allow me to use a semicolon as inner-any-pair text-object).

You can find some info for arguments tex-object and related operator in this old release notes. https://github.com/t9md/atom-vim-mode-plus/blob/master/CHANGELOG.old.md#0890

Untitled

bennypowers commented 5 years ago

mind blown Amazing. Thanks!