http://www.zinkwazi.com/unix/notes/tricks.vim.html
vi (aka vim) tutorial, tips, tricks and useful commands
Where grep came from (RE being Regular Expression):
:
g
/RE/
p
Delete lines 10 to 20 inclusive:
:
10
,
20
d
or with marks a and b:
:
'a
,
'b
d
Delete lines that contain pattern:
:
g
/pattern/
d
Delete all empty lines:
:
g
/^$/
d
Delete lines in range that contain pattern:
:
20
,
30
/pattern/
d
or with marks a and b:
:
'a
,
'b
/pattern/
d
Substitute all lines for first occurance of pattern:
:
%
s
/
pattern
/
new
/
:
1
,
$
s
/
pattern
/
new
/
Substitute all lines for pattern globally (more than once on the line):
:
%
s
/
pattern
/
new
/
g
:
1
,
$
s
/
pattern
/
new
/
g
Find all lines containing pattern and then append -new to the end of each line:
:%s
/
\(
.*pattern.*
\)/\1
-new
/g
Substitute range:
:
20
,
30
s/pattern/
new
/
g
with marks a and b:
:
'a
,
'b
s/pattern/
new
/
g
Swap two patterns on a line:
:s
/
\(
pattern1
\)\(
pattern2
\)
/
\2\1
/
Capitalize the first lowercase character on a line:
:s
/
\(
[a-z]
\)
/
\u
\1
/
more concisely:
:s
/
[a-z]
/
\u&
/
Capitalize all lowercase characters on a line:
:s
/
\(
[a-z]
\)
/
\u
\1
/
g
more concisely:
:s
/
[a-z]
/
\u&
/
g
Capitalize all characters on a line:
:s
/
\(
.*
\)
/
\U
\1
\E
/
Capitalize the first character of all words on a line:
:s
/
\<[a-z]
/
\u&
/
g
Uncapitalize the first character of all words on a line:
:s
/
\<[A-Z]
/
\l&
/
g
Change case of character under cursor:
~
Change case of all characters on line:
g
~~
Change case of remaining word from cursor:
g
~
w
Increment the number under the cursor:
<
Ctrl
-
A
>
Decrement the number under the cursor:
<
Ctrl
-
X
>
redraw:
<
Ctrl
-
L
>
Turn on line numbering:
:
set
nu
Turn it off:
:
set
nonu
Number lines (filter the file through a unix command and replace with output):
:%!cat
-
n
Sort lines:
:%!sort
Sort and uniq:
:%!sort
-
u
Read output of command into buffer:
:
r
!
ls
-
l
Refresh file from version on disk:
:
e
!
Open a new window:
<
Ctrl
-
W
>
n
Open a new window with the same file (split):
<
Ctrl
-
W
>
s
Split window vertically:
<
Ctrl
-
W
>
v
Close current window:
<
Ctrl
-
W
>
c
:
q
Make current window the only window:
<
Ctrl
-
W
>
o
Cycle to next window:
<
Ctrl
-
W
>
w
Move to window below current window:
<
Ctrl
-
W
>
j
Move to window above current window:
<
Ctrl
-
W
>
k
Move to window left of current window:
<
Ctrl
-
W
>
h
Move to window right of current window:
<
Ctrl
-
W
>
l
Set textwidth for automatic line-wrapping as you type:
:
set
textwidth
=
80
Turn on syntax highlighting
:
syn
on
Turn it off:
:
syn
off
Force the filetype for syntax highlighting:
:
set
filetype
=
python
:
set
filetype
=
c
:
set
filetype
=
php
Use lighter coloring scheme for a dark background:
:
set
background
=
dark
Htmlize a file using the current syntax highlighting:
:
so
$VIMRUNTIME
/
syntax
/
2
html
.
vim
Or, htmlize from a command prompt:
in 2html.sh put:
#!/bin/
sh
vim
-
n
-
c
':so $VIMRUNTIME/syntax/2html.vim'
-
c
':wqa'
$
1
>
/dev/null
2
>
/dev/null
Now just run: shell> 2html.sh foo.py
Document originally from http://www.cs.ualberta.ca/~luca/tricks.vim.html
updated and maintained by Greg Lawler
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script><script type="text/javascript">
var pageTracker = _gat._getTracker("UA-256828-4");
pageTracker._trackPageview();
</script>
分享到:
相关推荐
macos iterm2 zsh 高亮配色插件zsh-syntax-highlighting。This package provides syntax highlighting for the shell zsh. It enables highlighting of commands whilst they are typed at a zsh prompt into an ...
Anki的语法突出显示 允许您将语法突出显示的代码段插入到间隔重复的...查找并删除Syntax Highlighting.py文件(如果已存在)。 看看是否可以找到syntax_highlighting文件夹。 如果是这样: 如果文件夹包含meta.jso
zsh-syntax-highlighting
sublime text 3下的protobuf 语法高亮插件
sublime text3 对 proto buffer的语法高亮 源文件https://packagecontrol.io/packages/Protobuf%20Syntax%20Hightlighting
zsh高亮插件zsh-syntax-highlighting-master.zip。zsh-syntax-highlighting-master.zip
Idea和Android Studio【插件】全局自动设置代码高亮级别为 Syntax ...设置全局 highlighting level 为 Syntax 提升性能,更好地编辑代码! https://blog.csdn.net/sinat_27171121/article/details/129973447
MSC Patran 和 MSC Nastran 函数自动完成的语法定义以及 MSC Patran 命令语言 (PCL) 和 MSC Nastran 直接矩阵抽象程序 (DMAP) 的描述兼容的文件扩展名:*.ses *.pcl *.bdf *.f04 *。 f06 *.log *.rpt 查看更多信息到...
zsh-syntax-highlighting:鱼壳,如Zsh的语法突出显示
zsh-syntax-highlighting-filetypes:使用dircolors实时突出显示zsh语法
没有免费的午餐,想学...1. Syntax Highlighting 2. Code Completion and Basic Intellisense 3. Hover Information 4. Signature Help 5. Code Snippets 6. Format Document 7. Document Symbols 8. SRP Supports
优化和扩展zsh-syntax-highlighting
流星语法高亮一旦我们将使用它的站点(例如 SB、Cocos)升级到最新的 Meteor,可能需要升级到 >=0.9 包系统。
erics_nano_syntax_highlighting 目标:使代码的语法突出显示看起来像这样: HTML示例: 示例PHP: CSS示例: 安装说明。 将所有这些文件(someextension.nanorc)放在〜/ .nano / syntax目录下。 然后将其...
语言:English 此扩展将语法高亮显示添加到ElectricFlow UI中的“步骤”命令页面。 此chrome扩展程序允许用户在ElectricFlow的“编辑步骤”页面上打开和关闭语法高亮显示。 如果您是ElectricFlow用户,请在...
语言:English [beta]此扩展将语法突出显示到ElectriccomMander UI中的EditStep页面。 ... 请迁移到上述延期! 该Chrome扩展允许用户在ElectricCommander中的“编辑步骤”页面上切换突出显示和关闭。...
语言:English gChat的自动语法突出显示。 这个插件会自动检测您在与Google Talk交谈时键入代码的时间,并向其中添加语法突出显示功能。 -允许带有反引号的内联代码块-检测代码是否存在,并以正确的方式突出显示所述...
geshi-phpbb使用GeSHi语法突出显示工具为phpBB提供了MOD,用于语法突出显示。 它具有用于源代码,缓存和行编号的自定义样式,易于安装等。 由GeSHi创作者创作。
Set of classes for Automatic Syntax highlighting in a RichEdit Control for Delphi 5,6 and 7 Classes: TpsvPasRTF -- Delphi syntax highlight TpsvHTMLRTF -- HTML syntax highlight TpsvSQLRTF -- SQL syntax...