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` 是一个用于 Z shell 的语法高亮插件,它为命令行输入提供了丰富的颜色和样式,使用户在输入命令时可以更容易地识别出不同的语法元素,从而提高效率和减少错误。这个插件是开源社区的产物...
sublime text 3下的protobuf 语法高亮插件
标题"zsh-syntax-highlighting-master.zip"表明这是一个压缩文件,其中包含的是与ZSH(Z shell)相关的代码或插件。"zsh-syntax-highlighting-master"部分提示我们,这个插件专注于ZSH的语法高亮功能,而".zip"则...
sublime text3 对 proto buffer的语法高亮 源文件https://packagecontrol.io/packages/Protobuf%20Syntax%20Hightlighting
打开Keil5,进入“Tools”>“Options for Target”>“Editor”,在“Syntax Highlighting”部分,点击“Load”按钮,选择一个新的XML文件作为你的配色方案。 4. **转换VScode主题**:VScode的主题是JSON格式,而...
2. **语义高亮 (Semantic Highlighting)** 相较于语法高亮,语义高亮更进阶,它不仅基于代码的结构,还考虑了代码的含义和类型信息。VSCode 自 2019 年引入了语义高亮,它利用语言服务器协议 (Language Server ...
`zsh-syntax-highlighting` 是一个用于 Zsh(一种高级的 Unix shell)的插件,它为命令行输入提供了语法高亮显示的功能。这个功能极大地提升了用户在使用 Zsh 时的交互体验,使得命令行界面更加直观易读,尤其是在...
**phpBB Syntax Highlighting MOD-开源** 在网页论坛系统中,有时我们需要展示代码片段,而为了提高可读性和用户体验,代码高亮显示是必不可少的功能。`phpBB Syntax Highlighting MOD`是一个针对开源论坛软件phpBB...
zsh-syntax-highlighting-filetypes是一个zsh插件,它扩展了zsh-syntax-highlighting项目,为不同的文件类型提供特定的高亮显示。这个插件的目标是帮助用户更直观地理解命令行输入,提高代码的可读性和编辑效率。...
2. **开发新高亮器**:`zsh-syntax-highlighting`的设计允许添加新的高亮器。通过编写新的`_zsh_highlight_highlighter`函数,你可以实现对特殊语法或上下文的高亮。 3. **集成其他插件**:如果使用了其他`zsh`插件...
其中,代码高亮(Code Highlighting)是提高编程效率和代码可读性的重要特性。代码高亮插件能够让不同类型的代码元素以不同的颜色显示,使得代码结构更加清晰,有助于快速定位和理解代码。 【标题】"Android Studio...
`meteor-syntax-highlighting`是一个专为Meteor框架设计的包,它利用了Highlight.js库,提供了一种优雅的方式来为Objective-C和Swift等语言进行代码高亮显示。下面,我们将深入探讨这个包的使用、功能以及其与Meteor...
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 查看更多信息到...
《Brackets PDE Syntax Highlighting:深入理解JavaScript代码高亮》 在编程世界里,代码编辑器是开发者的重要工具,而代码高亮则是提升开发效率的关键特性之一。Brackets是一款开源的、轻量级的、现代的代码编辑器...
没有免费的午餐,想学...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
SHJS(Syntax Highlighting in JavaScript)是一个开源项目,专门用于在网页中实现代码高亮显示。这个JavaScript库允许开发者在不依赖服务器端处理的情况下,在客户端动态地对HTML文档中的源代码段落进行语法高亮。...