Ⅰ. 插件描述
Tags navigation - work in progressⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'gcmt/surfer-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'gcmt/surfer-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'gcmt/surfer-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/gcmt/surfer.vim
Ⅳ. 文档说明
## surfer.vim
This plugin provides a nice interface for searching and generating tags.
Requirements
- Vim 7.3+ compiled with Python 2.x support (2.6+).
- Exuberant Ctags (if you want Surfer to generate tags for you).
Installation
- First, you need to get Exuberant Ctags. This first step is required only if you want Surfer to generate tags by himself (see the3. option
g:surfer_generate_tagsfurther in the documentation). - Install Surfer with Vundle or Pathogen.
Troubleshooting: Usually Surfer is able to locate the correct tags program by himself, otherwise add the following line in your .vimrc:
let g:surfer_ctags_prg = "/path/to/ctags"Basic usage
Execute the :Surf command to search for tags in files in the current session. You can interact with search results with the following keys.
UP,TAB,CTRL+K: move up.DOWN,CTRL+J: move down.RETURN,CTRL+O,CTRL+G: jump to the selected tag.CTRL+P: open a preview window for the selected tag.CTRL+S: split the window for the selected tag.ESC,CTRL+C: close Surfer.CTRL+U: clear the current search.
Rememberer that when you jump to a tag you can easily jump back to the previous position with CTRL+T, as you would normally do in Vim.
Search profiles
Searches are not limited to the current session. In fact, you can use search profiles to widen or narrow the current search scope. A search profile is activated prepending to the search query a keyword followed by a colon. Surfer defines a few profiles for you:
$: this search profile set the search scope to all open buffers.%: this search profile narrows the search scope to the current buffer.
Basic options
g:surfer_ctags_prg
With this option you can set the path of the Ctags executable on your system. You usually need to do this only if Surfer is not able to locate the Ctags executable by himself.
Default: ""
g:surfer_smart_case
When this option is turned on, a search is case-insensitive only if you enter the search string in all lower case letters.
Default: 1
g:surfer_exclude_tags
With this option you can set a list of glob-style patterns used to exclude tags according to their name.
Example:
let g:surfer_exclude_tags = ["test_*", "__init__"]Default: []
g:surfer_exclude_kinds
With this option you can set a list of kind to be excluded. To get a list of the kinds that Ctags is able to recognize per language, execute the command $ ctags --list-kinds.
Example:
let g:surfer_exclude_kinds = ["namespace", "package"]Default: []
g:surfer_root_markers
With this option you can set file and directory names that are used to locate the root of the current project. At the current moment, this is used just when formatting search results.
Default: ['.git', '.svn', '.hg', '.bzr']
g:surfer_generate_tags
Turn this option off if you want to rely on a third party tag generator.
Default: 1
g:surfer_user_search_profiles
g:surfer_default_search_profile
Appearance
g:surfer_max_results
This option controls the maximum number of search results displayed.
Default: 15
g:surfer_line_format
This options controls the format of search results. This option is a list of strings and each one can contain at most one special placeholder that will be later substituted with the corresponding value. When the value for a placeholder is absent, the whole list item won't be displayed. Available placeholders vary across different languages but common placeholders include:
{file}: the file in which the tag is defined.{line}: the line of the tag in{file}.{kind}: the kind of the tag.{class}: the name of the class for which the tag is a member or method.{language}: the language of the file in which tags is defined.
Example:
let g:surfer_line_format = [" @ {file}", " ({line})", " {kind}"]Default: [" @ {file}", " ({line})"]
g:surfer_tag_file_format
With this option you can control how the file path of each tag is displayed in the search results list. Below a list of all possoble values:
: set an empty string to display the file path relative to the$HOMEdirectory.project: the file path is dispalyed relative to the current project, if exists.basename: only the basename of the file path is displayed.project|basename: if a project root exists, display the file path relative to it, otherwise display just the basename.custom:n: display a custom level of path depth. Here,nis a number that represent the number of parent directories to display.project|custom:n: if a project root exists, display the file path relative to it, otherwise display the file path with the custom level of path depth.
Default: "project|basename"
g:surfer_prompt
This option controls how the Surfer prompt looks.
Default: "@ "
g:surfer_current_line_indicator
This option controls how the current line indicator looks.
Default: " "
g:surfer_cursorline
Turn this option off to disable the cursorline vim option inside the Surfer window.
Default: 1
g:surfer_visual_kind
This option controls whether or not visual kinds appear and how they look. A visual kind is simply a colored visual representation of a tag kind. Set the option to an empty string to disable this feature.
Default: ""
Languages support
Exuberant Ctags only supports a limited set of languages ($ ctags --list-languages). If you need support for a new language you can rely on extending capabilities provided by Ctags itself that requires you to add some lines to the file $HOME/.ctags. If you search the web you'll certainly find out some prepackaged solutions suitable for your favorite language.
Check this link to learn how to integrate custom languages in Exuberant Ctags.