打开vim编辑器 vim/_Vim作为KMail的外部编辑器

打开vim编辑器 vim/

Vim is my favourite text editor and I also prefer to use Vim to compose Email. I ever used Vim as Thunderbird’s External editor with the help of plugin. I started to use KMail as my email client on KDE and I find it is not hard to configure KMail to use Vim as email editor with a little help from Konsole and shell.

Vim是我最喜欢的文本编辑器,我也更喜欢使用Vim编写电子邮件。 我曾经在插件的帮助下将Vim用作Thunderbird的外部编辑器 。 我开始在KDE上使用KMail作为我的电子邮件客户端,在Konsole和shell的帮助下,我发现配置KMail以将Vim用作电子邮件编辑器并不难。

kmail-external-editor-vim-konsole

KMail has a nice feature that can use external editor to compose email. In “Settings->Configure Kmail->Composor->General”, there is a option to “Use external editor instead of composer”, and we can specify the editor we like to use. The %f will be replaced with the file name of the email to edit which is copied to a temporary location.

KMail具有一项不错的功能,可以使用外部编辑器撰写电子邮件。 在“设置->配置Kmail->编写器->常规”中,有一个选项“使用外部编辑器代替编写器”,我们可以指定我们要使用的编辑器。 %f将替换为要编辑的电子邮件的文件名,该文件名将复制到一个临时位置。

It is possible to use KWrite as the editor and configure KWrite to use “Vi input mode”, but that is not convenient enough for geeks like me—I prefer the Vim in a shell/terminal!

可以使用KWrite作为编辑器,并将KWrite配置为使用“ Vi输入模式”,但这对于像我这样的极客来说还不够方便-我更喜欢在外壳/终端中使用Vim!

Now, let’s see how I use Vim in the shell as KMail’s external editor.

现在,让我们看看如何在外壳中使用Vim作为KMail的外部编辑器。

一个小的脚本作为调用Vim的包装器 (A small script as the wrapper to call Vim)

Vim is a command line tool and we can not directly run it. Instead, we should run Vim in a shell. In KDE, let’s just use Konsole. The external editor is actually a instance of Konsole with Vim as its command. Below is the script I wrote to invoke Konsole and Vim. Let’s call it kcallvim:

Vim是一个命令行工具,我们无法直接运行它。 相反,我们应该在shell中运行Vim。 在KDE中,我们仅使用Konsole。 外部编辑器实际上是使用Vim作为命令的Konsole实例。 下面是我编写的用于调用Konsole和Vim的脚本。 我们称之为kcallvim

#!/bin/bash

email=$1.eml
cp $1 $email

# --nofork is needed, otherwise the content is not updated
# no other konsole instance running
konsole --nofork --geometry 1000x600 -e vim $email

cp $email $1 && rm -f $email

One tricky thing here is the “–nofork” option when invoking konsole. This option make the konsole command not return until Vim exits.

这里一件棘手的事情是调用konsole时的“ –nofork”选项。 该选项使konsole命令在Vim退出之前不返回。

Put this script to a directory in the $PATH, or use the full path when invoking this script in Kmail.

将此脚本放在$ PATH中的目录中,或在Kmail中调用此脚本时使用完整路径。

配置KMail以将kcallvim用作外部编辑器 (Configure KMail to use kcallvim as the external editor)

In KMail’s configuration tool, select the option of “Use external editor instead of composer”, and, in the “external editor” field, fill

在KMail的配置工具中,选择“使用外部编辑器而不是作曲家”选项,然后在“外部编辑器”字段中填写

kcallvim %f

as shown in the figure.

如图所示。

kmail-external-editor-vim

That’s it. When composing or editing email, hit Enter or any key, the Vim will start in a Konsole. Then you can edit the email in Vim as editing any other text files. After you save the email and exit Vim, the Konsole will close automatically and the email will appear in KMail.

而已。 撰写或编辑电子邮件时,按Enter或任何键,Vim会在Konsole中启动 。 然后,您可以像编辑任何其他文本文件一样在Vim中编辑电子邮件。 保存电子邮件并退出Vim后,Konsole将自动关闭,并且该电子邮件将出现在KMail中。

翻译自: https://www.systutorials.com/vim-as-kmails-external-editor/

打开vim编辑器 vim/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值