如何将\\\网更改为vim中的常用字符? [英] How to change \u7f51 to common character in vim?

查看:149
本文介绍了如何将\\\网更改为vim中的常用字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在红宝石中,因为它在系统范围内是utf-8编码的。所以很简单:



string =\\\网\\\址\\\不\\\能\\\为\\\空



=>网址不能为空



任何人都可以告诉我如何在vim中执行此操作?

解决方案

如果您想插入Unicode字符,请参阅 utf-8-typing 帮助。 p>

例如, Ctrl-V u7f51 将插入网。



如果您想在Vim脚本中使用,可以使用与Ruby相同的Unicode转义;命令 echo\\\网\\\址\\\不\\\能\\\为\\\空将回显您在问题中提供的字符串。



意识到这一点, Ctrl-R 发挥作用, = 注册;请参阅 i_CTRL-R i_CTRL-R _ = 更多信息。



鉴于以下内容,光标位于双引号字符串中:

  string =\\\网\\\址\\\不\\\能\\\为\\\空

应用这些击键: c Ctrl-R = 控制-R 输入 Esc



这将会变成如下:

  string =网址不能为空

尝试弄清楚它是如何工作的,但我如果你不明白,会更多地解释。


In ruby, since it's utf-8 encoded in the system wide. so it's pretty straight forward:

string = "\u7f51\u5740\u4e0d\u80fd\u4e3a\u7a7a"

=>网址不能为空

Anyone can I tell me that how to do this in vim?

解决方案

If you are wanting to insert Unicode characters, see the utf-8-typing help.

For example, Ctrl-V u7f51 will insert 网.

If you are wanting it in Vim scripts, you can use Unicode escapes in the same way as in Ruby; the command echo "\u7f51\u5740\u4e0d\u80fd\u4e3a\u7a7a" will echo the string you provide in your question.

Being aware of this, Ctrl-R comes into play, with the " and = registers; see the docs for i_CTRL-R and i_CTRL-R_= for more info.

Given the following, with the cursor inside the double-quoted string:

string = "\u7f51\u5740\u4e0d\u80fd\u4e3a\u7a7a"

Apply these keystrokes: ci"Ctrl-R="Ctrl-R""EnterEsc

This will turn it into the following:

string = "网址不能为空"

Try to figure out how it works yourself, but I'll explain more if you can't figure it out.

这篇关于如何将\\\网更改为vim中的常用字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆