美文网首页
VIM 编辑器之神

VIM 编辑器之神

作者: bfx1000 | 来源:发表于2018-09-27 21:39 被阅读0次

说明:在这篇文章里面,<C-X> 代表 Ctrl + X——就是按住 Ctrl 键然后再按 X

vim三种模式

insert模式 按i 进入
normal模式 按ESC进入
virtual模式 按:进入
v可视化选择是一个很有意思的命令,你可以先按v,然后移动光标,你就会看到文本被选择
然后,你可能d,也可y,也可以变大写等

edit an existing file within vim.

:e d:test2.txt
#cmd prompt
vim d:cajview/welcome.txt

save a file as the aim path

saveas c:test2.txt
saveas c:\Users\administrator\Desktop\test2.txt
saveas c:/Users/administrator/Desktop/test2.txt
saveas ~/Desktop/test2.txt

大小写转换

gU (变大写)
gu (变小写)

vim文本编辑----移动(move)

0 → 到行头
$ → 到行尾
^ → 到本行的第一个非blank字符
<C-f>mean page down
<C-b>mean page up
normal模式下:
h、j、k、l分别代表左、下、上、右
0 移动到行首
$ 移动到行尾
gg 移动到篇首
G 移动到篇尾
79gg  跳转到79行(79G)
30j  means move down 30 lines
2w  move behind 2 words' beginning
3e  move behind 3 words and locate the end of third word
ce  erase a word and insert mode
0y$ means copy a line from beginning to end
ye means copy a word from current position
y2/foo means copy string between the first foo and the second foo

vim文本编辑----查找和替换(select and replace)

w 移动到下一个单词字首
e 移动到当前单词尾
f {char} F{char} 查找下\上一个字符,之后按;继续查找
t{char} T{char} 向后/前查找单个字符左侧字符,之后按;继续查找
:%s/i'm/I'm/g 全局替换把i'm替换成I'm
:n1,n2s/word1/word2/g   means replace word1 with word2

select

/tihuan
to select string "tihuan" in full text, button "n" to select the next, 
"N" opposite select.
?tihuan
to select string above from current position

vim文本编辑----insert

i  insert before cursor 
a  append after cursor
A  append something at the last of a line
o  insert a void row below cursor
O  insert a void row above cursor

vim文本编辑----删除(delete)

normal模式下,
x  删除当前光标一个字符,接着用.重复删除字
dd 删除一行数据,然后用.重复删除一行数据 
dw 删除到下一个单词
de 删除本单词
d$ 删除从光标到行尾
dG 删除从光标到结尾

段落删除

delete 1 row\delete 1-10 rows
:1d
:1,10d

vim文本编辑----复制粘贴(copy&paste)

yy #copy the current line to your clipboard
2yy 复制本行和下面1行
:reg 查看各个黏贴板内容
"2p 粘贴2号剪切板
"+y 复制到系统剪切板
"+p 黏贴系统剪切板内容

点操作
# <backspace>和正常的输入都将作为命令的一部分, 且该命令是可以重复执行的。通过 . 来实现
d剪切,p粘贴,例如剪切一行并粘贴
dd
p


vim多行复制(或几个单词复制)

移动光标到复制开始的地方按V,移动光标到复制结束的地方按y,移动到粘贴位置按P

vim文本编辑----新建与保存

在默认路径 **c:\\Users\\用户名** 下新建一个名为welcome.txt的文件并打开(在cmd中)
vim welcome.txt
# 退出且不保存
:q!<ENTER>
# 保存退出
:wq<ENTER>
# 对未命名文件命名为 welcome.txt
:file welcome.txt
对于没有指定 Vim 的保存文件路径,指定路径
:cd c:\User\admin

vim文本编辑----缩进

单行缩进,normal下,当前段落*向左、向右*缩进分别是:
<<
>>
批量缩进,normal下,2到9行向右缩进一个tab/两个tab
:2,9> 
:2,9>>

the dot order

. → (小数点) 可以重复上一次的命令
N<command> → 重复某个命令N次

2dd → 删除2行
3p → 粘贴文本3次
3idesu [ESC] → 会写下 “desu desu desu“
. → 重复上一个命令—— 3 “desu “.
2. → 重复 2次 “desu” (注意:不是 6 times,你看,VIM多聪明啊).

Annotation many lines

VISUAL mode select targets
ctrl+v
Input upper case 'I'
Input #

相关文章

  • vim简单操作与配置

    vim 编辑器之神Emacs 神的编辑器 vim配置 ~/.vimrc 配置文件 vimplugin 管理vim插...

  • Vi与Vim编辑器命令笔记的精髓

    1、Vim & Emacs 1.1、神奇的传说 Emacs是神的编辑器 Vim是编辑器之神 Vim&Emacs 1...

  • Linux系统学习之:vim编辑器

    Vim编辑器号称编辑器之神,当然系统学习Vim知识量偏多,需要专门整理,此处仅列出少量部分。 Vim编辑器模式: ...

  • VIM编辑器简单快速上手

    1.VIM简介 vim被称为编辑器之神(Emacs被称为神之编辑器) 2.安装vim 安装环境:ubuntu14....

  • vim

    vim编辑器之神 配置vimrc配置 在shell中可以通过 vim ~/.vimrc 或者 vim /etc/v...

  • Day5 vim编辑器操作

    vim编辑器之神 配置vimrc配置 在shell中可以通过 vim ~/.vimrc 或者 vim /etc/v...

  • 【CLI】Vim和Emacs调研

    参考文章: Emacs和Vim:神的编辑器和编辑器之神 为什么这么多人喜欢使用Vim或Emacs? Vim和Ema...

  • Vim简洁教程

    原文链接 VIM 在编辑界一直有两大传说:Vim——编辑器之神,Emacs——神之编辑器。而我是坚定的VIM党,至...

  • 66/70 vim基础

    vim 和 emacs 一个号称编辑器之神,一个被称为神的编辑器。打开 vim 执行命令:vimtutor 则可以...

  • Vim——编辑器之神

    世界上只有两款编辑器可以撕逼,那就是Vim(编辑器之神)和Emacs(神的编辑器、操作系统) Vim优势 Linu...

网友评论

      本文标题:VIM 编辑器之神

      本文链接:https://www.haomeiwen.com/subject/vocrsftx.html