如何在没有富文本格式的情况下复制和粘贴代码?

发布于 2024-07-05 14:11:26 字数 391 浏览 7 评论 0原文

我曾经经常发现自己从网站/Word 文档等中处理一段代码,却发现在进行粘贴时,我最终会得到所需的代码以及一些额外的 HTML 标签/文本,基本上是额外的格式信息。

为了摆脱多余的镇流器,我会将文本粘贴到记事本,然后再次复制,然后粘贴到所需的目的地。

最近,我发现了一个简单且免费的 Windows 工具,名为 PureText,它可以让我省去记事本步骤。 它基本上添加了一个额外的键盘快捷键,例如 WinKey + V,可以执行粘贴操作而无需格式化; 只是纯文本。 我觉得它非常方便。

我想知道您自己会使用什么方法? 它们是否有更好/更容易使用的工具?

I used to often find myself coping a piece of code from a website/Word document etc only to discover that when doing Paste I would end up with the desired code plus some extra HTML tags/text, basically extra formatting information.

To get rid of that extra ballast I would paste the text to the Notepad and then copy it again and then paste to the desired destination.

Pretty recently I discovered a simple and free tool for Windows called PureText that allows me to cut the Notepad step. It basically adds an extra keyboard shortcut e.g WinKey + V that will do the Paste action without formatting; just pure text.
I find it very handy.

I was wondering what approach would you use yourselves? Are they any better/easier to use tools around?

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

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

发布评论

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

评论(13

浮生面具三千个 2024-07-12 14:11:26

如果您使用的是 MS Word,请尝试 ALT+E、S、U、Enter(使用选择性粘贴)

If you are using MS Word then try ALT+E, S, U, Enter (Uses the Paste Special)

離人涙 2024-07-12 14:11:26

很高兴发现您的 PureText。 在更换键盘之前,我已经构建了一个正在运行宏的按键,该宏在记事本中复制粘贴复制以完成此任务! 我会尝试一下你的软件,因为我现在没有任何宏键:(

Nice find with your PureText. I had build, before I change keyboard, a key that was running a macro that was copying-pasting-copying in notepad for this task! I'll give a try to your software since I do not have any macro key now :(

〗斷ホ乔殘χμё〖 2024-07-12 14:11:26

我编写了一个未发布的 java 应用程序来监视剪贴板,将提供文本和其他更丰富格式的项目替换为仅提供纯文本格式的项目。

I wrote an unpublished java app to monitor the clipboard, replacing items that offered text along with other richer formats, with items only offering the plain text format.

給妳壹絲溫柔 2024-07-12 14:11:26

查找在您粘贴的材料末尾弹出的一个剪贴板小图标。 单击此按钮并选择“仅保留文本”。

Look for a little clipboard icon that pops up at the end of the material you pasted. Click on this and choose "keep text only".

⒈起吃苦の倖褔 2024-07-12 14:11:26

我使用 OpenOffice.org,它提供了一个粘贴特殊选项,您可以在其中完全省略格式设置。 如果您没有绑定 MS Word,那么 IMO 值得一试,而且它是免费的:-)

I use OpenOffice.org and that offers a paste special option, where you can omit the formatting altogether. If you are not bound to MS Word, it's IMO worth a try and it's free :-)

浴红衣 2024-07-12 14:11:26

每当这些插件和选项不可用时,我就使用我的好朋友记事本。 将内容粘贴到记事本中,记事本不接受额外的格式,然后将其复制回来。 有点老套,但是哦,好吧。 有用!

Whenever these plugins and options aren't available I just use my good ol friend notepad. Paste content into notepad where it won't accept the extra formatting and then copy it right back out. Sort of hacky but oh well. It works!

梦纸 2024-07-12 14:11:26

我通常使用 Notepad2,我从网络复制的所有文本都会粘贴到那里然后重复使用,这使我可以清理它(从格式中删除并进行修改)。

您可以在此处下载 Notepad2

I usually work with Notepad2, all the text I copy from the web are pasted there and then reused, that allows me to clean it (from format and make modifications).

You can download Notepad2 here

萌吟 2024-07-12 14:11:26

我将 Far.exe 作为开始中的第一项菜单。

剪贴板中的富文本 ->

ctrl-escape,arrdown,enter,shift-f4,$,enter
shift-insert,ctrl-insert,alt-backspace,
f10,enter

-> 剪贴板中的纯文本

优点:没有鼠标,只是盲输入,完全在我之前的位置结束

缺点:ANSI 编码 - 国际符号丢失

幸运的是,我不必经常这样做:)

I have Far.exe as the first item in the start menu.

Richtext in the clipboard ->

ctrl-escape,arrdown,enter,shift-f4,$,enter
shift-insert,ctrl-insert,alt-backspace,
f10,enter

-> plaintext in the clipboard

Pros: no mouse, just blind typing, ends exactly where i was before

Cons: ANSI encoding - international symbols are lost

Luckily, I do not have to do that too often :)

始终不够 2024-07-12 14:11:26

如果要粘贴到 Word 中,可以使用“选择性粘贴”命令。

If you're pasting into Word you can use the Paste Special command.

相思碎 2024-07-12 14:11:26

在网站上,使用 Firefox,我使用 CopyPlainText< /a> 扩展名。

From websites, using Firefox, I use the CopyPlainText extension.

夏九 2024-07-12 14:11:26

我是 自动热键
我定义了一个适用于任何应用程序的“粘贴纯文本”宏。 当我按 Ctrl+Shift+V 并粘贴剪贴板上任何内容的普通版本时,它就会运行。 Autohotkey 的好处是:您可以编写代码,使其按照您希望的方式在所有应用程序中工作。

^+v::
    ; Convert any copied files, HTML, or other formatted text to plain text
    Clipboard = %Clipboard%

    ; Paste by pressing Ctrl+V
    SendInput, ^v
return

I'm a big fan of Autohotkey.
I defined a 'paste plain text' macro that works in any application. It runs when I press Ctrl+Shift+V and pastes a plain version of whatever is on the clipboard. The nice thing about Autohotkey: you can code things to work the way you want them to work across all applications.

^+v::
    ; Convert any copied files, HTML, or other formatted text to plain text
    Clipboard = %Clipboard%

    ; Paste by pressing Ctrl+V
    SendInput, ^v
return
别挽留 2024-07-12 14:11:26

仅供参考,在 Mac OS X 下,您可以使用 ⌘ Command+⇧ Shift+V 进行粘贴,无需格式化或使用“当前”格式。

注意:在某些应用程序中,它是 ⌘ Command+⇧ Shift+⌥ Alt+V(请参阅“编辑”菜单→“粘贴并匹配样式”)

Just for reference, under Mac OS X, you can use ⌘ Command+⇧ Shift+V to paste without formatting or with the "current" format.

Note: in some apps it's ⌘ Command+⇧ Shift+⌥ Alt+V (see "Edit" Menu → "Paste and Match Style")

好倦 2024-07-12 14:11:26

总结一下可用的选项:

工具

浏览器

  • 的建议,要复制来自浏览器:复制为纯文本CopyPlainText (由 cori) - Firefox 扩展
  • 粘贴而不格式化到浏览器(至少 Firefox/Chrome): Windows/Linux 上的 CTRL+⇧ Shift+V,对于 Mac OS X,请参阅下文。

其他

  • Mac OS X 下,您可以 ⇧ Shift+ ⌥ Alt+⌘ Command+V 以“当前”格式粘贴(编辑 -> 粘贴并匹配风格); 或 ⌘ Command+⇧ Shift+V 进行不带格式粘贴(通过 Kamafeather)
  • 粘贴到记事本(或其他文本编辑器),然后从记事本复制并再次粘贴
  • 对于单行文本:粘贴到任何非富文本字段(浏览器 URL、文本区域、搜索/查找输入等)

请随意编辑/添加新项目

Just to summarize the available options:

Tools

Browsers

  • To copy plain text from a browser: Copy As Plain Text or CopyPlainText (suggested by cori) - Firefox extensions
  • To paste without formatting to a browser (Firefox/Chrome at least): CTRL+⇧ Shift+V on Windows/Linux, see below for Mac OS X.

Other

  • Under Mac OS X, you can ⇧ Shift+⌥ Alt+⌘ Command+V to paste with the "current" format (Edit -> Paste and Match Style); or ⌘ Command+⇧ Shift+V to paste without formatting (by Kamafeather)
  • Paste to Notepad (or other text editor), and then copy from Notepad and paste again
  • For single-line text: paste to any non-rich text field (browser URL, textarea, search/find inputs, etc.)

Please feel free to edit/add new items

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文