将花括号格式化为内联的有效方法

Anw*_*war 2 vim

将花括号移动到同一行的最快方法是什么?

由此:

const value = { 
    input: 123 
}
Run Code Online (Sandbox Code Playgroud)

对此:

const value = { input: 123 }
Run Code Online (Sandbox Code Playgroud)

我这样做的方法是将 Visual 与 hjkl 结合使用。

奖励:我怎样才能实现编辑,但反过来呢?

Lig*_*ght 6

  1. 将光标置于第一个{.
  2. v,然后按shift+ %
  3. shift+ j

注意:如果未配对{}存在于注释/字符串/等中,该行为可能会中断。