*tips.txt*       Vim version 6.2.   : 2002 Oct 29


		        VIM -  


     Vim 		               *tips* **

      " ",
|usr_toc.txt|.

   C			|C-|
 ,   		|-|
   xterm			|xterm-|
   			|-_|
 				|_|
  			||
ޣ ,   .. 			|ޣ__|
  			|_|
 				|_|
                  |__|
 			        |_|
       		        |gzip-|
    	        |_|
  		|hex-|
  <>  	|-<>|

==============================================================================
   		        *C-editing* *-*

 Vim         . 
   :

|usr_29.txt|		   ,   
|usr_30.txt|		 ,   
|C-|		    
			     C
|=|			     
|-|
			 

|:checkpath|		   ޣ 
|[i|			 ,       
			   ޣ .
|[_CTRL-I|		    "[i"
|[I|			      ޣ , 
			       .
|[d|			  #define    ޣ
			   .

|CTRL-]|		     (,  
			   ).
|CTRL-T|		     CTRL-].
|:tselect|		     .

|gd|			      .
|gD|			     
			   .

|gf|			     .

|%|			    (), {}, [], /* */, #if,
			   #else, #endif.
|[/|			    .
|]/|			    .
|[#|			    #if, #ifdef  #else.
|]#|			 ң   #else  #endif.
|[(|			    '('
|])|			 ң   ')'
|[{|			    '{'
|]}|			 ң   '}'

|v_ab|			 ""  "[("  "])",  
|v_ib|			 " "  "[("  "])"
|v_aB|			 ""  "[{"  "]}",  
|v_iB|			 " "  "[{"  "]}"

==============================================================================
 ,   	            *ident-search* *-*

, ,  ,  ||    , 
   .    
   ,       
.     :
1.   |:grep|.      
   Unix-,       (grep  
   )       .
2.      ID utils.   
         .   
       .    
    ,       
   .

 GNU id-tools:

  :
-     GNU id-tools (  mkid 
     ID  lid   ).
-   ͣ "ID"   .      
   "mkid file1 file2 ...".

    .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
	endfun

     ,  "_u"  Vim  , 
   .       
     "n",     --  
"_n"/

    id-utils-3.2 (    id-tools 
ftp- GNU).

[   ]

==============================================================================
                                                     *xterm-_*
				                                *xterm-*
   xterm		   *xterm-screens* *xterm-save-screen*

( comp.editors,      )

:> ݣ  .    Vim    , .. 
:>    ,   .  
:> ,  "ls", , ..      
:> .  ,     
:>     Vim     Vi.    ,
:>   .  .  .
:
:,    -  .    , 
:Vim  Vi          xterm.

 ,       ,    
 termcap vs. terminfo.   ,     
      : termcap  terminfo. 
   ,   ,     
   terminfo,   termcap (.  |+terminfo|).

     ģ   
^[[?47h  ^[[?47l.       
  xterm.       
 : >
	
	echo -n "^[[?47h"; vim ... ; echo -n "^[[?47l"

,  . ( ^[   ESC,   ,
       \E).

 , Vim      termcap ti (
terminfo: smcup).  , Vim  te (terminfo: rmcup). 
     .

    xterm ( /etc/termcap)   xterm  terminfo
(, /usr/5bin/infocmp -C xterm).     
: >

	:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:

PS:   ģ ,  - (?)   
    termcap  terminfo   .

 1:    Vim   FEAT_XTERM_SAVE
(   feature.h,    xterm   "te" 
"ti".

 2:         
 termcap,      .vimrc : >
	
	:set t_ti= t_te=

==============================================================================
   	     *scroll-insert* *-_*

          , 
   CTRL-X CTRL-E  CTRL-X CTRL-Y.
|i_CTRL-X_CTRL-E|

    ,    : >

	:inoremap <C-E> <C-X><C-E>
	:inoremap <C-Y> <C-X><C-Y>

     , ,   '<'  
   'cpoptions').
        /
 |i_CTRL-E|.

     'scrolloff': ţ    
      .   
'scrolloff'   ,      
 ,         .

==============================================================================
 			    *scroll-smooth* *_*

      ,    
: >

	: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>

(   ,     '<'  
 'cpoptions').

==============================================================================
  			    *type-mistakes* **

          ,  
     .
: >

	:ab teh the
	:ab fro for

==============================================================================
ޣ ,   .. 	      *count-items* *ޣ__*

          
,    'report'  0   
      .  ,  
       . : >

	:set report=0
	:%s/./&/g		
	:%s/\i\+/&/g		
	:%s/^			
	:%s/the/&/g		"the"    
	:%s/\<the\>/&/g		"the"   

    'hlsearch'    ":nohlsearch".

   ,    'modifiable'.    
     |v_g_CTRL-G|.

==============================================================================
  	   *restore-position* *_*

   ,    - 
-         ,  
. ,      : >

   :map <F2> msHmtgg/ []:\s*/e+1<CR>"_D"=strftime("%Y %b %d")<CR>p'tzt`s

  :
	ms	     's'
	H	    
	mt	    't'

  :
	't	  ,     
	zt	    
	`s	    

==============================================================================
 			*rename-files* *_*

,    ,     :

buffer.c
charset.c
digraph.c
...

    *.c  *.bla.    : >

	$ vim
	:r! ls *.c
	:%s/\(.*\).c/mv & \1.bla
	:w !sh
	:q!

==============================================================================
         *speed-up* *__*

         .
 Unix          . 
      .

   .cshrc (  ,     )
 ,        :  
 ,     ,
..   .       Vim, 
  (,   )  
.         .cshrc
 : >

	if ($?prompt == 0) then
		exit 0
	endif

      "-f"   'shell', ..: >

	:set shell=csh\ -f

(         ).
  csh     .cshrc.  , , 
    .

==============================================================================
 			 *useful-mappings* *_*

  ,    .

				    *map-backtick* *-_*
>
	:map ' `

     .    
   ,  ,     
 .

					           *emacs-keys* *-emacs*

      Emacs: >

	"  
	:cnoremap <C-A>		<Home>
	"    
	:cnoremap <C-B>		<Left>
	"    
	:cnoremap <C-D>		<Del>
	"  
	:cnoremap <C-E>		<End>
	" ң   
	:cnoremap <C-F>		<Right>
	"      
	:cnoremap <C-N>		<Down>
	"      
	:cnoremap <C-P>		<Up>
	"    
	:cnoremap <Esc><C-B>	<S-Left>
	" ң   
	:cnoremap <Esc><C-F>	<S-Right>


:  ,   '<'     
'cpoptions'. |<>|

				 *format-bullet-list* *_*
    .  ţ   
     .     , 
     . >

	:let m =     ":map _f  :set ai<CR>"   "   'autoindent'
	:let m = m . "{O<Esc>"		      "    
					      " 
	:let m = m . "}{)^W"		      "    
	                                      "    
					      "  
	:let m = m . "i     <CR>     <Esc>"   "    
	:let m = m . "gq}"		      "   
					      "    
					      " 
	:let m = m . "{dd"		      "   
	:let m = m . "5lDJ"		      "   
					      "     
	:execute m			      |"  

(   <> |<>|.  ,   
 . ^W  "^" "W",   CTRL-W.   '<'  
  'cpoptions',       
    .

 ,      |",  
 ":execute"    . 

      'textwidth'  
, : >
	
	:set tw=70

,     ,  ң     
: >

	:map _f :set ai<CR>}{a                                                          <Esc>WWmmkD`mi<CR><Esc>kkddpJgq}'mJO<Esc>j

(:         
).

					    *collapse* *__*
       (;b)  
(;n)     >

    :map ;b   GoZ<Esc>:g/^$/.,/./-j<CR>Gdd
    :map ;n   GoZ<Esc>:g/^[ <Tab>]*$/.,/[^ <Tab>]/-j<CR>Gdd

==============================================================================
       		     *gzip-helpfile* *gzip-*

 ,       ,    
   .       
  Vim.         
  "gzip".

(1)    : "gzip doc/*.txt".

(2)   "doc/tags"   ".txt"  ".txt.gz": >

	:%s=\(\t.*\.txt\)\t=\1.gz\t=

(3)    vimrc  : >

	set helpfile={}/help.txt.gz

 {}   ,    .  |gzip| 
    .
  ,  $VIMRUNTIME  , ..  
 ,    Vim,     ,
       . . |$VIMRUNTIME|.

==============================================================================
    	        *shell-window* *_*

          Vim.
:  !       
  Vim,   أ    . Vim
 ,        .    ,
          
 "splitvt",     ftp-.   
    (Sam Lantinga, <slouken@cs.ucdavis.edu>). 
   "window",     BSD Unix
.       . 
  "screen",     
(www.uni-erlangen.de).

==============================================================================
                                                           *-xxd*
				                          *hex-*
  	             *hex-editing* *using-xxd* 

.  |23.4| .

      -  
(, exe, bin  ..),      
     <.vimrc>.  "*.bin"
  ,   ,    
     : >

	" vim -b :     xxd!
	augroup Binary
	  au!
	  au BufReadPre  *.bin let &bin=1
	  au BufReadPost *.bin if &bin | %!xxd
	  au BufReadPost *.bin set ft=xxd | endif
	  au BufWritePre *.bin if &bin | %!xxd -r
	  au BufWritePre *.bin endif
	  au BufWritePost *.bin if &bin | %!xxd
	  au BufWritePost *.bin set nomod | endif
	augroup END

==============================================================================
  <>  	 *autocmd-<>* *-<>*

 <>      :autocmd.  
  ,  
        <> 
     . : 

                                 *map-self-destroy*  *_*
>
 "      .  
 "  !
 " 1.       ''     \.
 " 2.    '"'
 " 3.       
 " !  :    ,
 "     "i"
 "
 autocmd BufNewFile,BufReadPre * nmap i :nunmap i<CR>O<C-R>%<Esc>:.g/\./s/\./\\./g<CR>0"9y$u:menu Buffers.<C-R>9 :buffer <C-R>%<C-V><CR><CR>
 autocmd BufNewFile,BufReadPre * normal i

 ,    --   ":execute". 
     <>,   
  .       
       '"'. >
>
  autocmd BufNewFile,BufReadPre * exe "normal O\<C-R>%\<Esc>:.g/\\./s/\\./\\\\./g\<CR>0\"9y$u:menu Buffers.\<C-R>9 :buffer \<C-R>%\<C-V>\<CR>\<CR>"

        (.
|:function|),      <>  .  
       <>  .

==============================================================================
vim:tw=78:ts=8:ft=help:norl:
