2012-06-01 32 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' –