On 8月19日, 下午7时11分, Christian Brabandt <[email protected]> wrote: > Hi eliweiq001! > > On Do, 19 Aug 2010, eliweiq001 wrote: > > > I am using a portable edition of gVim in windows. > > I have to open gVim and then open a .c file every time,( for learning > > programing ), so I want a function and map a key to it, then I can > > open the file very quickly. > > Maybe It would be better that the function can both run in windows and > > linux. > > Please don't top poste. > > Here is a simple example: > > #v+ > fun! OpenLastModified(...) > let path=(a:1 ? a:1 : getcwd() ) > let files=split(glob(path . '/*', 1), '\n') > call filter(files, '!isdirectory(v:val)') > call sort(files, "CompareLastModified") > return files[-1] > endfun > > func! CompareLastModified(a,b) > return getftime(a:a) == getftime(a:b) ? 0 : getftime(a:a) > getftime > (a:b) ? 1 : -1 > endfunc > > com! -complete=dir -nargs=? EditLastModified :exe ':tabe ' . > OpenLastModified(<q-args>) > #v- > > Use :OpenLastModified to open the last modified file in your current > working directory or optionally use tab completion to use any other > directory. > > regards > Christian
Thanks very much! I will try it. And exactly I want to open the lastest modified *.c file. How to put this .c into your function? -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
