VIM TIP33
在帮助文档里关闭行号
I like the line-number for myself editing. But I hate it in on-line help page because it force the screen wrapped.
我喜欢在自己编辑时有行号。但是我讨厌在帮助文档里边的行号,因为这样使屏幕转行了。
:au filetype help :se nonu
Technorati Tags: VI, EDITOR
To find and replace one or more occurences of a given text pattern with a new text string, use the s[ubstitute] command. 为了查找替换文中出现过的一个或多个文本串,使用s命令 There are a variety of options, but these are what you most probably want: 有很多可选的变量,看看什么是你最需要的: :%s/foo/bar/g find each occurance of 'foo' and replace it with 'bar' without asking for confirmation 不确认替换每一个foo为bar :%s/foo/bar/gc find each occurance of 'foo' and replace it with 'bar' asking for confirmation first 首次向用户确认并替换每一个foo为bar :%s//bar/gc find (match exact word only) and replace each occurance of 'foo' with 'bar' 将一个词foo替换为bar :%s/foo/bar/gci find (case insensitive) and replace each occurance of 'foo' with 'bar' 大小写不敏感替换foo为bar :%s/foo/bar/gcI find (case sensitive) and replace each occurance of 'foo' with 'bar' 大小写敏感替换foo为bar
NB: Without the 'g' flag, replacement occurs only for the first occurrence in each line. NB: 没有g选项的话,仅仅替换每行的第一个匹配项 For a full description and some more interesting examples of the substitute command refer to 想知道替换详细的解释和一些有趣的例子请参考 :help substitute
See also: 或者: :help cmdline-ranges :help pattern :help gdefault
fu! LineIt()
exe ":s/^/".line(".")."/"
endf
v' also perform a search but it match the line not match the
canonical expression.<br>2.<b>g</b> 表明作用域将是整个文件,一般使用在搜索中。'<b>v</b>'也在搜索中使用但是不能使用正则表达式。<br>3.<b> /</b> begins the regular express<br>3.<b>/</b>开始正则表达式<br>4.<b> ^ </b>is a special character respect the start of a line.<br>4.<b> ^</b>使表示行首的元字符<br>5. the second<b> /</b> ends the regular express and indicate that the remains is action to do.<br>5. 第二个<b>/</b>在正则表达式的末尾,并表明有后续操作<br>6. <b>m</b> means move,
tand
co' for copy, `d' for deletefunction! Hex2Dec()usage:
let lstr = getline(".")
let hexstr = matchstr(lstr, '0x[a-f0-9]+')
while hexstr != ""
let hexstr = hexstr + 0
exe 's#0x[a-f0-9]+#'.hexstr."#"
let lstr = substitute(lstr, '0x[a-f0-9]+', hexstr, "")
let hexstr = matchstr(lstr, '0x[a-f0-9]+')
endwhile
endfunction
import java.util.Hashtable; ^M
import java.util.Properties; ^Mimport java.io.IOException;
import org.xml.sax.AttributeList; ^M
import org.xml.sax.HandlerBase; ^Mimport org.xml.sax.SAXException;
/**^M
* XMLHandler: This class parses the elements contained^M
* within a XML message and builds a Hashtable^M
I frequently hold the shift key for too long when typing, for instance :wq, and end up with :Wq. Vim then whines "Not an editor command: Wq" 我时常在输入的时候按住shift键,比如:wq当以:Wq录入时,Vim会提示“无:Wq命令”的错误 In my .vimrc, I have taught vim my common typos: 在我的.vimrc配置中,我讲设置如下等价录入 command! Q quit command! W write command! Wq wq this one won't work, because :X is already a built-in command command! X xit 如果不生效的话,那是应为:X已然是内置的命令!X xit了。
Here are some pointers to the vim documentation. Notice that the mechanism is different in vim 6.0 and vim 5.x. 这有一些vim文档的指导。注意其中vim6.0和5.x版本的构架区别。
I want .foo files to be highlighted like HTML files. 1.我希望.foo 文件按照HTML文件进行语法高亮。 :help new-filetype http://www.vim.org/html/autocmd.html#new-filetype
I want to define a syntax file for *.bar files. Read the above and also
我希望定义一个*.bar语法高亮文件。请参考上边文件 :help mysyntaxfile http://www.vim.org/html/syntax.html#mysyntaxfile
I want to make a few changes to the existing syntax highlighting. Depending on the x in 5.x, either read the above and page down a few screens, or you may be able to skip right to
我希望对已有的语法高亮文件进行一些改变。在5.x环境下的x,阅读以上的文件和下文,或者直接跳到 :help mysyntaxfile-add http://www.vim.org/html/syntax.html#mysyntaxfile-add
I want to change some of the colors from their defaults. Again, read 4.我想改变默认语法高亮的颜色配置。请读:
:help mysyntaxfile http://www.vim.org/html/syntax.html#mysyntaxfile