在正常模式下使用常规粘贴 (p) 会破坏缩进 - vim

发布于 2024-11-30 01:00:26 字数 307 浏览 1 评论 0原文

我看到有一个 set Paste 选项,可以在从终端 vim 中的系统剪贴板粘贴时允许正确的缩进,但我错过了如何使用 p< 从 vim 的缓冲区“内部剪贴板”粘贴/code> 或 P 命令并将 = 应用于粘贴的文本。到目前为止,我都是手动执行此操作。

执行 set Paste 或其相反操作不会修复粘贴文本的缩进。

你能帮它做一个 .vimrc 映射吗?或者有一个内置选项吗?

谢谢。

I saw that there is an set paste option that allows correct indentation when pasting from the system clipboard in terminal vim, but I miss how to paste from vim's buffer "inner clipboard" with the p or P command and apply = to the pasted text. Until now I manually do that.

Doing set paste or its inverse doesn't fix the indentation for the pasted text.

Could you help making a .vimrc mapping for it ? Or is there an built-in option for that ?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

刘备忘录 2024-12-07 01:00:26

]p]P 命令将粘贴内容并将其放置在当前行的缩进处,而不是使用复制行的原始缩进。例如:

line 1
line 2
    line 3
    line 4

复制第 2 行和第 2 行3,移动到第 3 行并按 ]p 将导致

line 1
line 2
    line 3
    line 2
        line 3
    line 4

The ]p and ]P commands will paste and place the contents at the indentation of the current line instead of using the original indentation of the copied lines. For example:

line 1
line 2
    line 3
    line 4

Copying lines 2 & 3, moving to line 3 and pressing ]p would result in

line 1
line 2
    line 3
    line 2
        line 3
    line 4
羁拥 2024-12-07 01:00:26

]p]P

尝试来自 :help p

["x]]p              or                                  ]p ]<MiddleMouse>
["x]]<MiddleMouse>      Like "p", but adjust the indent to the current line.
                        Using the mouse only works when 'mouse' contains 'n'
                        or 'a'.  {not in Vi}

["x][P              or                                  [P
["x]]P              or                                  ]P
["x][p              or                                  [p [<MiddleMouse>
["x][<MiddleMouse>      Like "P", but adjust the indent to the current line.
                        Using the mouse only works when 'mouse' contains 'n'
                        or 'a'.  {not in Vi}

Try ]p and ]P

From :help p:

["x]]p              or                                  ]p ]<MiddleMouse>
["x]]<MiddleMouse>      Like "p", but adjust the indent to the current line.
                        Using the mouse only works when 'mouse' contains 'n'
                        or 'a'.  {not in Vi}

["x][P              or                                  [P
["x]]P              or                                  ]P
["x][p              or                                  [p [<MiddleMouse>
["x][<MiddleMouse>      Like "P", but adjust the indent to the current line.
                        Using the mouse only works when 'mouse' contains 'n'
                        or 'a'.  {not in Vi}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文