2012-06-01 31 views
25

在Vim中,当我通过输入/x对“x”进行增量搜索时,然后按n跳转到下一个出现位置。如果我刚刚匹配文件的最后一个匹配项,当我按n时,光标将开始在文件的开始处查找匹配项 - 它将循环回到开头。 我不希望它回到起点。我希望n在到达最终发生后根本找不到任何匹配。我想要这种行为的原因是,我可以很容易地看到我搜索整个文件的时间。vim渐进式搜索停止在文件结尾

有谁知道如何影响这种行为?

FYI:我使用以下的.vimrc选项:

colorscheme zenburn " zenburn colorscheme 

set nocompatible  " prevent Vim from emulating Vi's bugs 
set scrolloff=5  " keeps cursor away from top/bottom of screen 
set nobackup   " don't make automatic backups 

set incsearch   " incremental searching 
set ignorecase  " case insensitive matching 
set smartcase   " smart case matching 
set showmatch   " show matching bracket 

set autoindent  " indentation 
set smartindent  " indentation 
set cindent   " indenting for C code 
set tabstop=4   " 4-space tabs 
set shiftwidth=4  " 4-space tabs 

syntax on    " syntax highlighting 
filetype on   " behavior based on file type 
filetype plugin on " behavior based on file type 
filetype indent on " behavior based on file type 

set visualbell  " replace beeping with flashing screen 

set gfn=Lucida_Sans_Typewriter:h10:cANSI 

回答

36

关闭'wrapscan'选项。

set nowrapscan 
+0

谢谢,我知道它必须是直接和简单的东西:) – synaptik

+2

我刚刚添加这行到我的'〜/ .vimrc'。当我需要包装时,我会做一个':1' –