简体   繁体   English

在emacs中转换结构化文本块

[英]transform structured text block in emacs

I want to learn from expert about how to transform this text from 我想向专家学习如何从

    sa.Column('id', sa.Integer, primary_key=True),
    sa.Column('title', sa.String(100)),
    sa.Column('isbn', sa.String(20)),
    sa.Column('authors',sa.String(400),nullable=False),
    sa.Column('year',sa.Integer,nullable=False)

to

  id          = Column(Integer, primary_key=True)
  title       = Column(String(100))
  isbn        = Column(String(20))
  authors     = Column(String(400),nullable=False)
  year        = Column(Integer,nullable=False)

using either macro of multi-cursor. 使用多光标宏。 Please shed some light. 请说明一下。

This is how I did it, though my general advice would be just to look at it a couple of times, find what the general things are, then record a macro (sometimes including mistakes; do it over again, or continue if it isn't harmful) 我就是这样做的,尽管我的一般建议只是看几次,找到一般的东西,然后记录一个宏(有时包括错误;再做一次;如果不是,请继续执行)。有害)

<start recording>

Macro:

C-SPC               ;; set-mark-command
<C-right>           ;; right-word
<right>             ;; right-char
C-.                 ;; mark-next-like-this
<backspace>         ;; delete-char
2*<C-right>         ;; right-word
2*<right>           ;; right-char
2*<backspace>       ;; delete-char
M-DEL               ;; backward-kill-word
<backspace>         ;; delete-char
M-\                 ;; delete-horizontal-space
C-e                 ;; end-of-line
<backspace>         ;; delete-char
C-a                 ;; beginning-of-line
C-y                 ;; yank
SPC                 ;; self-insert-command
=                   ;; self-insert-command
SPC                 ;; self-insert-command
C-a                 ;; beginning-of-line
<down>              ;; next-line

<end recording>

我会使用多个光标来同时编辑所有行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM