您的位置:首页 > 其它

vim实用功能备忘

2016-07-07 23:40 363 查看
Copyright 2016 by 蔡舒啸 保持署名-非商业性使用-相同方式共享 Creative Commons BY-NC-ND 3.0

目录

使用系统剪贴板
其他程序复制到 vim

vim 到其他程序复制

其他剪贴板

全选

快速移动键盘光标

多行缩进

多余的话
vim 乌干达儿童援助项目

使用系统剪贴板

vim 不支持系统剪贴板

vim-gnome 支持系统剪贴板

vim-gtk 支持系统剪贴板

结论:

1) 如果你是服务器运维, 常年在纯命令行模式下使用系统, 也就根本不存在”系统剪贴板”的需求

2) 如果你使用桌面版Linux 比如 Ubuntu , 请确保卸载了原版 vim 后, 再安装 vim-gnome, 或 vim-gtk

Ubuntu 16.04 64位系统下, 博主亲测可用:

sudo apt purge vim
sudo apt install vim-gnome
vim


其他程序复制到 vim

在其他地方按
ctrl C
在 vim 中按
Esc
再逐个按
"
,
+
,
p
三个一个都不能少, 就在键盘光标位置插入了复制的内容.

vim 到其他程序复制

Esc
再按
V
, 按方向键移动键盘光标选中一些文字

"
,
+
,
y
三个一个都不能少, 把选中的内容复制到系统剪贴板. 然后在别的程序按
Ctrl V
就能黏贴了.

其他剪贴板

查看 vim 全部剪贴板的内容: 在 vim 中按
Esc
再按
:reg
回车, 可以看到除了
"+
外还有名为

"1
,
"2
, … ,
"9
,
"-
,
".
,
"%
,
"/
等剪贴板

Esc
再按
"1y
,
"2y
, … ,
"9y
,
"-y
,
".y
,
"%y
,
"/y
就能复制这些内容

全选

Esc
再依次按下
g
,
g
,
Shift V
,
Shift G


快速移动键盘光标

vim打开文件

按ESC进入浏览模式

shift+4 行首

shift+6 行尾

多行缩进

ESC
回到浏览模式, 按一次
V
, 按方向键(
H
,
L
,
J
,
K
)移动光标选中要缩进的行,
Shift+句号
向右缩进一个tab

常见于javascript或java中调整代码缩进

多余的话

用过Eclipse, IDEA, Sublime, Atom之后, 我一度偏激的认为, vim 是一个伟大但已经过时的软件.

渐渐地, 我发现vim不是一无是处,用 vim 时用键盘就能完成大多数命令,这点还是非常先进的。在命令行下,确实只有 vim 相对好用。

知乎上看到的一句话:折腾vim没有想死过3次的人不算会用vim。

深以为然。我在研究生一年级折腾过vim只想死了一次,还差得很远呢。否定之否定, 螺旋上升的认识.

很多现代编辑器 github atom 和 sublime 都有 vim 模式插件,这再一次证明了vim的价值。

vim 乌干达儿童援助项目

软件应该让世界变得美好, 如果你写的软件做不到, 至少你还能通过助人为乐来帮助这个世界

About half of the children sponsored through ICCF are in higher education. They do not live and study in Kibaale but go to a boarding school, far away from home. And these studies are tough. Only the best students are accepted and even then they struggle to pass exams. Fortunately we have not had a drop-out in two years.

A good example is Kaweesi Emmanuel. He finished secondary school in Kibaale in 2007, with very good grades. He did A-levels in Masaka and again finished with very good scores, 23 out of 25 points. He then wanted to study law in Kampala. That is a five year study, a big commitment for the sponsor. Fortunately the sponsor agreed. Then there were problems applying for the study, but in September 2010 he could finally start his first year at Makerere university.

After five years of tough studies and the sponsor paying large yearly payments, Emmanuel graduated for the law degree in January 2015. But that’s not the end yet! Another year of Bar course at the Law Development Centre was required. Emmanual has finished this now and the final graduation was April 29th. He is the first lawyer to come out of our sponsorship program!

We are very proud of Emmanuel. He comes from a poor family, sleeping on the floor in a tiny house with no electricity, water or TV.

And now he is a lawyer!

He is an example for other children who sometimes need a bit of motivation for their studies.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  vim ubuntu