Ãâ·Ñ×¢²á ²é¿´ÐÂÌû |

Chinaunix

  ƽ̨ ÂÛ̳ ²©¿Í ÎÄ¿â
×î½ü·ÃÎʰå¿é ·¢ÐÂÌû
²é¿´: 1369 | »Ø¸´: 2
´òÓ¡ ÉÏÒ»Ö÷Ìâ ÏÂÒ»Ö÷Ìâ

[ѧϰ¹²Ïí] vim С֪ʶ [¸´ÖÆÁ´½Ó]

ÂÛ̳»ÕÕÂ:
0
Ìø×ªµ½Ö¸¶¨Â¥²ã
1Â¥ [ÊÕ²Ø(0)] [±¨¸æ]
·¢±íÓÚ 2017-02-02 11:57 |Ö»¿´¸Ã×÷Õß |µ¹Ðòä¯ÀÀ
±¾Ìû×îºóÓÉ wyc198801wyc ÓÚ 2017-02-02 12:01 ±à¼­

ÔÚvimÍøÕ¾ÉÏ¿´µ½Á˸öÓÐÒâ˼µÄÓ÷¨¸ú´ó¼Ò·ÖÏíһϣ¬¹²Í¬Ñ§Ï°¡£

      Sessions Ó÷¨

Suppose you are editing along, and it is the end of the day.  You want to quitwork and pick up where you left off the next day.  You can do this by savingyour editing session and restoring it the next day.   A Vim session contains all the information about what you are editing.This includes things such as the file list, window layout, global variables,options and other information.  (Exactly what is remembered is controlled bythe 'sessionoptions' option, described below.)   The following command creates a session file:
:mksession vimbook.vim

Later if you want to restore this session, you can use this command:

:source vimbook.vim

If you want to start Vim and restore a specific session, you can use thefollowing command:

vim -S vimbook.vim

This tells Vim to read a specific file on startup.  The 'S' stands forsession (actually, you can source any Vim script with -S, thus it might aswell stand for "source").The windows that were open are restored, with the same position and size asbefore.  Mappings and option values are like before.   What exactly is restored depends on the 'sessionoptions' option.  The default value is "blank,buffers,curdir,folds,help,options,winsize".  

      blank                   keep empty windows     
      buffers                 all buffers, not only the ones in a window      
      curdir                   the current directory   
      folds                    folds, also manually created ones   
      help                     the help window      
      options                 all options and mappings      
      winsize                 window sizesChange this to your liking.  

To also restore the size of the Vim window, forexample, use:

  :set sessionoptions+=resize

SESSION HERE, SESSION THEREThe obvious way to use sessions is when working on different projects.Suppose you store you session files in the directory "~/.vim".  You arecurrently working on the "secret" project and have to switch to the "boring"project:

   :wall
   :mksession! ~/.vim/secret.vim
   :source ~/.vim/boring.vim

This first uses ":wall" to write all modified files.  Then the current sessionis saved, using ":mksession!".  This overwrites the previous session.  Thenext time you load the secret session you can continue where you were at thispoint.  And finally you load the new "boring" session.If you open help windows, split and close various window, and generally messup the window layout, you can go back to the last saved session:

   :source ~/.vim/boring.vim

ÂÛ̳»ÕÕÂ:
0
2Â¥ [±¨¸æ]
·¢±íÓÚ 2017-02-02 23:56 |Ö»¿´¸Ã×÷Õß
±¾Ìû×îºóÓÉ wyc198801wyc ÓÚ 2017-02-03 00:07 ±à¼­

vim -x secret_file          ΪÎļþ¼ÓÃÜÂë

g CTRL-G                 ÏÔʾ¹â±êÔÚµÚ¼¸byteµÈÐÅÏ¢
200go                      µ½µÚ200byte

`"                           ¹â±êÒÆµ½ÉÏ´ÎÍ˳öµÄµØ·½
`.                           ¹â±êÒÆµ½ÉϴθıäµÄµØ·½

ÂÛ̳»ÕÕÂ:
6
³ÌÐòÉè¼Æ°æ¿éÿÈÕ·¢ÌûÖ®ÐÇ
ÈÕÆÚ:2015-12-05 06:20:00Êý¾Ý¿â¼¼Êõ°æ¿éÿÈÕ·¢ÌûÖ®ÐÇ
ÈÕÆÚ:2016-02-06 06:20:00Êý¾Ý¿â¼¼Êõ°æ¿éÿÈÕ·¢ÌûÖ®ÐÇ
ÈÕÆÚ:2016-03-07 06:20:00³ÌÐòÉè¼Æ°æ¿éÿÈÕ·¢ÌûÖ®ÐÇ
ÈÕÆÚ:2016-06-04 06:20:00ºÚÂü°Í
ÈÕÆÚ:2017-02-06 16:31:2615-16Èü¼¾CBAÁªÈüÖ®¹ãÏÄ
ÈÕÆÚ:2017-05-07 09:02:07
3Â¥ [±¨¸æ]
·¢±íÓÚ 2017-02-06 16:13 |Ö»¿´¸Ã×÷Õß
лл·ÖÏí man vim
ÄúÐèÒªµÇ¼ºó²Å¿ÉÒÔ»ØÌû µÇ¼ | ×¢²á

±¾°æ»ý·Ö¹æÔò ·¢±í»Ø¸´

  

±±¾©Ê¢ÍØÓÅѶÐÅÏ¢¼¼ÊõÓÐÏÞ¹«Ë¾. °æÈ¨ËùÓÐ ¾©ICP±¸16024965ºÅ-6 ±±¾©Êй«°²¾Öº£µí·Ö¾ÖÍø¼àÖÐÐı¸°¸±àºÅ£º11010802020122 niuxiaotong@pcpop.com 17352615567
δ³ÉÄê¾Ù±¨×¨Çø
Öйú»¥ÁªÍøÐ­»á»áÔ±  ÁªÏµÎÒÃÇ£ºhuangweiwei@itpub.net
¸ÐлËùÓйØÐĺÍÖ§³Ö¹ýChinaUnixµÄÅóÓÑÃÇ ×ªÔØ±¾Õ¾ÄÚÈÝÇë×¢Ã÷Ô­×÷ÕßÃû¼°³ö´¦

Çå³ý Cookies - ChinaUnix - Archiver - WAP - TOP