📄 global.txi
字号:
@end example@item If you examine vi's source,@example $ cd /usr/src/usr.bin/vi $ gtags $ nvi -G -t main@end exampleYou can start from nvi and browse the whole unix world as if you wereusing hypertext.@end itemize@c ***************************************************************************@c Nvi-1.81.5 editor@c ***************************************************************************@node Nvi-1.81.5 editor@section nvi-1.81.5 using GLOBAL.You can use GLOBAL as a tag system of Nvi editor instead of ctags.@menu* Features(nvi-1.81.5):: Features.* Preparation(nvi-1.81.5):: Preparation.* Basic usage(nvi-1.81.5):: Basic usage.@end menu@c ***************************************************************************@node Features(nvi-1.81.5)@subsection Features.@itemize @bullet@itemYou can use most of GLOBAL's facilities from the editor.@itemRecognition of the current token and its type.@end itemize@c ***************************************************************************@node Preparation(nvi-1.81.5)@subsection Preparation.First, do the preparation of global. @xref{Preparation}.Second, to use global from nvi, you need write to @file{.nexrc} like this:It assumed that gtags.pl is put on @file{$HOME/perl}.@example $HOME/.nexrc +---------------------------- |perl use lib "$ENV@{'HOME'@}/perl" |perl require 'gtags.pl' |map ^P :tagprev^M |map ^N :tagnext^M |map ^] :perl tag^M |ab gtag perl tag qw( |ab gta perl tag qw( |ab gt perl tag qw(@end exampleYou must start nvi under the source tree described in @ref{Preparation}.@c ***************************************************************************@node Basic usage(nvi-1.81.5)@subsection Basic usage.@itemize @bullet@item To go to func1, you can say@example :perl tag qw(func1)@end example@example Suggested .nexrc: ab gtag perl tag qw( ab gta perl tag qw( ab gt perl tag qw(@end example@item To go to the referenced point of func1, add the option @kbd{-r}@example :perl tag qw(-r func1)@end example@item If a number of objects are located, nvi goes to the first tag.You can go to next tag by typing @kbd{:tagnext} and back by typing @kbd{:tagprev}.@example Suggested .nexrc: map ^N :tagnext^M map ^P :tagprev^M@end example@item If you don't specify any argument. ':perl tag' command do the followins:If current token is not a function then it is equivalent to@kbd{:perl tag qw(-s @var{current token})}.Otherwise, if you are in the first column of a line,it is equivalent to @kbd{:perl tag qw(-r @var{current token})} else it is equivalentto @kbd{:perl tag qw(@var{current token})}.@example Suggested .nexrc: map ^] :perl tag^M@end exampleIt is similar to @kbd{CTL-]} command.@item You can use the @kbd{-s} option. It locates any symbols which are notdefined in @file{GTAGS}.@example :perl tag qw(-s pat)@end example@item The @kbd{-g}, @kbd{-f} and @kbd{-P} option are also available.It works like command line.@example :perl tag qw(-g pat)@end example@item When you want to check objects the name of which start with "set" or "get", use:@example :perl tag qw(^[sg]et)@end example@item Other tag commands are also available:@table @code@item @kbd{CTL-T}Return to the most recent tag context.@item @kbd{:tagpop}Go to the specified tag in the tags stack.@item @kbd{:tagtop}Go to the top tag in the tags stack.@item @kbd{:display tags}Display the tags stack.@end table@end itemize@c ***************************************************************************@c Elvis editor@c ***************************************************************************@node Elvis editor@section Elvis using globalElvis 2.1 has new @code{tagprg} and @code{tagprgonce} variables forrunning an external tag search program. You can use them with GLOBAL.@menu* Features(elvis):: Features.* Preparation(elvis):: Preparation.* Basic usage(elvis):: Basic usage.* Applied usage(elvis):: Applied usage.@end menu@c ***************************************************************************@node Features(elvis)@subsection Features.@itemize @bullet@itemYou can use most of GLOBAL's facilities from the editor.@itemNo source level patch is needed.@itemMouse events are supported.@end itemize@c ***************************************************************************@node Preparation(elvis)@subsection Preparation.First, do the preparation of global. @xref{Preparation}.Second, start elvis and execute @code{set tagprg="global -t $1"} like this.@opindex -t@example $ elvis ~ ~ ~ ~ ~ ~ :set tagprg="global -t $1"@end example@c ***************************************************************************@node Basic usage(elvis)@subsection Basic usage.@itemize @bullet@item To go to func1, you can say@example :tag func1@end exampleIt seemes the same as original elvis, but elvis execute @code{global -t func1}internally and read it instead of tags file.@item To go to the referenced point of func1, add @samp{-r} option.@opindex -r@example :tag -r func1@end exampleElvis executes command like @code{global -t -r func1} internally.@item To go to any symbols which are not defined in @file{GTAGS}, try this.@opindex -s@example :tag -s lbolt@end example@item To go to any strings other than symbols, try this.@opindex -g@example :tag -g Copyright@end example@item When using -r, -s or -g, you had better to use browse command.@example :browse -r fork@end exampleIt brings a following selection list. You can select tag and go tothe point.@example Browse -r fork (2 matches) +----------------+----------------+-------------------- | TAG NAME | SOURCE FILE | SOURCE LINE +----------------+----------------+-------------------- |fork |ux/linux_misc.c | (line 565) |fork |ern/init_main.c | (line 191) +----------------+----------------+--------------------@end example@item To get list of objects in a file, use -f command.@opindex -f@example :browse -f main.c <- @r{locate definitions in main.c}@end example@item Other tag commands are also available:@table @code@item @kbd{CTL-]} go to the definition of current token.@item @kbd{CTL-T} return to the most recent tag context.@item @kbd{:tag} without argument, go to the next tag.@item @kbd{:pop} return to the most recent tag context.@item @kbd{:stack} display the tags stack.@item @kbd{:stag} creates a new window and moves its cursor to the tag's definition point.@item @kbd{:sbrowse} same with 'browse' but show in a new window.@end table@end itemize@c ***************************************************************************@node Applied usage(elvis)@subsection Applied usage.@itemize @bullet@item You can use POSIX regular expressions.@opindex -g@example :tag ^put_ <- @r{locate objects start with 'put_'} :browse -g 'fseek(.*L_SET)' <- @r{locate fseek() using L_SET argument}@end example@item You can browse object list of many files.@opindex -f@example :browse -f *.c <- @r{locate objects in *.c}@end example@item You can browse project files whose path includs specified pattern.@opindex -P@example :browse -P /vm/ <- @r{under vm/ directory} :browse -P \.h$ <- @r{all include files} :browse -P init <- @r{path including 'init'}@end example@item You can use mouse to select tag.@example +----------------+----------------+-------------------- | TAG NAME | SOURCE FILE | SOURCE LINE +----------------+----------------+-------------------- |fork |ux/linux_misc.c | (line 565) |fork |ern/init_main.c | (line 191) +----------------+----------------+--------------------@end examplePlease select tag name with mouse cursor and double click on the leftbutton and you go to the tag's point.In source screen, also select an object name and double click on theleft button and you can go to the point that the object is defined.To come back, double click on the right button.@end itemize@c ***************************************************************************@c Vim editor@c ***************************************************************************@node Vim editor@section Vim using globalIn vim 6.2 or later, you can use gtags.vim script.@menu* Features(vim):: Features.* Preparation(vim):: Preparation.* Basic usage(vim):: Basic usage.* Applied usage(vim):: Applied usage.@end menu@c ***************************************************************************@node Features(vim)@subsection Features.@itemize @bullet@itemYou can use most of GLOBAL's facilities from the editor.@itemIntelligent recognition of the current token and its type.@itemSpecial character '%', '#' and input completion are available.@end itemize@c ***************************************************************************@node Preparation(vim)@subsection Preparation.First, do the preparation of global. @xref{Preparation}.Second, copy @file{gtags.vim} to your plugin directory or source itfrom your vimrc.@example $ cp /usr/local/share/gtags/gtags.vim $HOME/.vim/plugin@end example@c ***************************************************************************@node Basic usage(vim)@subsection Basic usage.@itemize @bullet@item To go to main, you can say@example :Gtags main@end exampleVim execute @code{global -t main}, parse the output, list locatedobjects in quickfix window and load the first entry.The quickfix windows is like this:@examplegctags/gctags.c|119| mainglobal/global.c|154| maingozilla/gozilla.c|156| maingtags/gtags.c|199| mainlibglibc/getopt.c|701| mainlibglibc/getopt1.c|93| main[Error List]@end exampleYou can go to any entry using quickfix command.@table @code@item @kbd{:cn} go to the next entry.@item @kbd{:cp} go to the previous entry.@item @kbd{:ccN} go to the N'th entry.@item @kbd{:cl} list all entries.@end tableYou can see the help of quickfix like this:@example :h quickfix@end example@item To go to the referenced point of func1, add @samp{-r} option.@opindex -r@example :Gtags -r func1@end examplevim executes command like @code{global -t -r func1} internally.@item To go to any symbols which are not defined in @file{GTAGS}, try this.@opindex -s@example :Gtags -s lbolt@end example@item To go to any strings other than symbols, try this.@opindex -g@example :Gtags -g Copyright@end example@item To get list of objects in a file, use -f command.@opindex -f@example :Gtags -f main.c <- @r{locate objects in main.c}@end exampleIf you are editing @file{main.c} itself, you can use '%' instead.@example :Gtags -f % <- @r{locate objects in main.c}@end example@end itemize@c ***************************************************************************@node Applied usage(vim)@subsection Applied usage.@itemize @bullet@item You can use POSIX regular expressions.@opindex -g@example :Gtags ^put_ <- @r{locate objects start with 'put_'} :Gtags -g fseek(.*SEEK_SET) <- @r{locate fseek() using SEEK_SET}@end example@item Input completion is available. :Gtags fu@kbd{TAB} :Gtags func1 <- @r{'nc1' is appended by vim}@item You can browse project files whose path includes specified pattern.@opindex -P@example :Gtags -P /vm/ <- @r{under vm/ directory} :Gtags -P \.h$ <- @r{all include files} :Gtags -P init <- @r{path including 'init'}@end example@item You can use all options of global(1) except for the -c, -p, -u and all long name options. They are sent to global(1) as is. For example,@example :Gtags -gi paTtern <- @r{match to both 'PATTERN' and 'pattern'.}@end example About the other options, @xref{global}.@item The GtagsCursor command brings you to the definition or reference of the current token in C language. The GtagsCursor is not perfect though is considerably wise. If current token is not a function then it is equivalent to @kbd{:Gtags -s @var{current token}}. Otherwise, if you are in the first column of a line, it is equivalent to @kbd{:Gtags -r @var{current token}} else it is equivalent to @kbd{:Gtags @var{current token}}.@example :GtagsCursor@end example@example Suggested map: map <C-]> :GtagsCursor<CR>@end example@item If you have the hypertext generated by htags(1) then you can display the same place on mozilla browser. Let's load mozilla and try this:@example :Gozilla@end example@example Suggested map: map <C-g> :Gozilla<CR>@end example@item If you want to load vim with all main()s then following command line is useful.@example
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -