⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tips.txt

📁 MSYS在windows下模拟了一个类unix的终端
💻 TXT
📖 第 1 页 / 共 2 页
字号:
*tips.txt*      For Vim version 5.8.  Last change: 2000 Feb 09		  VIM REFERENCE MANUAL    by Bram MoolenaarTips and ideas for using Vim				*tips*Editing C programs				|C-editing|Finding where identifiers are used		|ident-search|Editing local HTML files (WWW)			|html-editing|Editing paragraphs without a line break		|edit-no-break|Switching screens in an xterm			|xterm-screens|Scrolling in Insert mode			|scroll-insert|Smooth scrolling				|scroll-smooth|Correcting common typing mistakes		|type-mistakes|Counting words, lines, etc.			|count-items|Restoring the cursor position			|restore-position|Renaming files					|rename-files|Speeding up external commands			|speed-up|Useful mappings					|useful-mappings|Compressing the help files			|gzip-helpfile|Hex editing					|hex-editing|Executing shell commands in a window		|shell-window|Using <> notation in autocommands		|autocmd-<>|==============================================================================Editing C programs					*C-editing*There are quite a few features in Vim to help you edit C program files.  Hereis an overview with tags to jump to:|C-indenting|		Automatically set the indent of a line while typing			text.|=|			Re-indent a few lines.|format-comments|	Format comments.|:checkpath|		Show all recursively included files.|[i|			Search for identifier under cursor in current and			included files.|[_CTRL-I|		Jump to match for "[i"|[I|			List all lines in current and included files where			identifier under the cursor matches.|[d|			Search for define under cursor in current and included			files.|CTRL-]|		Jump to tag under cursor (e.g., definition of a			function).|CTRL-T|		Jump back to before a CTRL-] command.|:tselect|		Select one tag out of a list of matching tags.|gd|			Go to Declaration of local variable under cursor.|gD|			Go to Declaration of global variable under cursor.|gf|			Go to file name under the cursor.|%|			Go to matching (), {}, [], /* */, #if, #else, #endif.|[/|			Go to previous start of comment.|]/|			Go to next end of comment.|[#|			Go back to unclosed #if, #ifdef, or #else.|]#|			Go forward to unclosed #else or #endif.|[(|			Go back to unclosed '('|])|			Go forward to unclosed ')'|[{|			Go back to unclosed '{'|]}|			Go forward to unclosed '}'|v_ab|			Select "a block" from "[(" to "])", including braces|v_ib|			Select "inner block" from "[(" to "])"|v_aB|			Select "a block" from "[{" to "]}", including brackets|v_iB|			Select "inner block" from "[{" to "]}"==============================================================================Finding where identifiers are used			*ident-search*You probably already know that |tags| can be used to jump to the place where afunction or variable is defined.  But sometimes you wish you could jump to allthe places where a function or variable is being used.  This is possible intwo ways:1. Using "grep" and quickfix commands.  This should work on most Unix systems,   but can be slow (it reads all files) and only searches in one directory.2. Using ID utils.  This is fast and works in multiple directories.  It uses a   database to store locations.  You will need some additional programs for   this to work.  And you need to keep the database up to date.1. Using grep.Add one long line to your .vimrc:>  map _g :let efsave=&ef<Bar>let &ef=tempname()<Bar>exe ':!grep -n -w "<cword>" *.[cChH] *.cc *.cpp *.txt >'.&ef<CR>:cf<CR>:exe ":!rm ".&ef<CR>:let &ef=efsave<Bar>unlet efsave<CR><CR>:cc<CR>NOTE: This requires that the '<' flag is excluded from 'cpoptions'.That's all!  You can use this by placing the cursor on any identifier, andhitting "_g".  Then go to further matches with ":cn".  ":cc" and ":cp" can beused to move around in the list of matches.  Use ":cl" to see all matches.Also see |quickfix|.This depends on the format of what grep produces and 'errorformat'.  It shouldwork with the default settings.Not all versions of "grep" accept the "-w" argument.  You can try if replacing	-w "<cword>"with this>	"\<<cword>\>"works for you.  A drawback is often that the '_' character is treated like anon-word character.  Thus "msg" will also match "msg_row".2. With a combination of Vim and the GNU id-tools.This is still is a rather simple tool, but it works.What you need:- Vim 5.0 or later.- The GNU id-tools installed (mkid is needed to create ID and lid is needed to  use the macros).- An identifier database file called "ID" in the current directory.  You can  create it with the shell command "mkid file1 file2 ..".Put this in your .vimrc:>	map _u :call ID_search()<Bar>execute "/\\<" . g:word . "\\>"<CR>>	map _n :n<Bar>execute "/\\<" . g:word . "\\>"<CR>>>	function ID_search()>	  let g:word = expand("<cword>")>	  let x = system("lid --key=none ". g:word)>	  let x = substitute(x, "\n", " ", "g")>	  execute "next " . x>	endfunTo use it, place the cursor on a word, type "_u" and vim will load the filethat contains the word.  Search for the next ocurance of the word in the samefile with "n".  Go to the next file with "_n".This has been tested with id-utils-3.2 (which is the name name of the id-toolsarchive file on your closest gnu-ftp-mirror).[the idea for this comes from Andreas Kutschera]==============================================================================Editing local HTML files (WWW)				*html-editing*Vim has some features which can help simplify the creation and maintenance ofHTML files, provided that the files you are editing are available on the localfile system.  The "]f", "gf" and "CTRL-W f" commands can be used to jump tothe file whose name appears under the cursor, thus not only checking that thelink is valid (at least the file name part of the URL) but also providing aquick and easy way to edit many related HTML pages at once.  |gf|A set of macros to help with editing html can be found on the Vim pages. |www|If you want to view your HTML file, after writing a new version with Vim, havea look at the "atchange" program.  It can be used to automatically start aviewer when the last-changed date/time of a file changes.  You can find infoat: http://www-lmmb.ncifcrf.gov/~toms/atchange.html==============================================================================Editing paragraphs without a line break			*edit-no-break*If you are typing text in Vim that will later go to a word processor, it isuseful to keep a paragraph as a single line.  To make this more easy:- set 'wrap' on, to make lines wrap				|'wrap'|- set 'linebreak' on, to make wrapping happen at a blank	|'linebreak'|- set 'textwidth' to zero, to avoid linebreaks			|'tw'|- use "gk" and "gj" to move one screen line up or down		|gj|You might also want to set 'showbreak' to recognize a line that is wrapped:>	:set showbreak=>>>==============================================================================Switching screens in an xterm		*xterm-screens* *xterm-save-screen*(From comp.editors, by Juergen Weigert, in reply to a question):> Another question is that after exiting vim, the screen is left as it:> was, i.e. the contents of the file I was viewing (editting) was left on:> the screen. The output from my previous like "ls" were lost,:> ie. no longer in the scrolling buffer. I know that there is a way to:> restore the screen after exiting vim or other vi like editors,:> I just don't know how. Helps are appreciated. Thanks.::I imagine someone else can answer this.  I assume though that vim and vi do:the same thing as each other for a given xterm setup.They not necessarily do the same thing, as this may be a termcap vs.terminfo problem. You should be aware that there are two databases fordescribing attributes of a particular type of terminal: termcap andterminfo. This can cause differences when the entries differ AND when ofthe programs in question one uses terminfo and the other uses termcap(also see |+terminfo|).In your particular problem, you are looking for the control sequences^[[?47h and ^[[?47l. These switch between xterms alternate and main screenbuffer. As a quick workaround a command sequence like>	echo -n "^[[?47h"; vim ... ; echo -n "^[[?47l"may do what you want. (My notation ^[ means the ESC character, further downyou'll see that the databases use \E instead).On startup, vim echoes the value of the termcap variable ti (terminfo:smcup) to the terminal. When exiting, it echoes te (terminfo: rmcup). Thusthese two variables are the correct place where the above mentioned controlsequences should go.Compare your xterm termcap entry (found in /etc/termcap) with your xtermterminfo entry (retrieved with /usr/5bin/infocmp -C xterm). Both shouldcontain entries similar to:>	:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:PS: If you find any difference, someone (your sysadmin?) should better check    the complete termcap and terminfo database for consistency.NOTE 1: If you recompile Vim with SAVE_XTERM_SCREEN defined in feature.h, thebuiltin xterm will include the mentioned "te" and "ti" entries.NOTE 2: If you want to disable the screen switching, and you don't want tochange your termcap, you can add these lines to your .vimrc:>	:set t_ti= t_te===============================================================================Scrolling in Insert mode				*scroll-insert*If you are in insert mode and you want to see something that is just off thescreen, you can use CTRL-X CTRL-E and CTRL-X CTRL-Y to scroll the screen.						|i_CTRL-X_CTRL-E|To make this easier, you could use these mappings:>	:inoremap <C-E> <C-X><C-E>>	:inoremap <C-Y> <C-X><C-Y>(Type this literally, make sure the '<' flag is not in 'cpoptions').You then lose the ability to copy text from the line above/below the cursor|i_CTRL-E|.Also consider setting 'scrolloff' to a larger value, so that you can always seesome context around the cursor.  If 'scrolloff' is bigger than half the windowheight, the cursor will always be in the middle and the text is scrolled whenthe cursor is moved up/down.==============================================================================Smooth scrolling					*scroll-smooth*If you like the scrolling to go a bit smoother, you can use these mappings:>	:map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y>>	:map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E>(Type this literally, make sure the '<' flag is not in 'cpoptions').==============================================================================Correcting common typing mistakes			*type-mistakes*When there are a few words that you keep on typing in the wrong way, makeabbreviations that correct them.  For example:>	:ab teh the>	:ab fro for

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -