Hi yosi!
On Mi, 10 Jun 2009, yosi izaq wrote:
> Now, I guess you mean by your answer that I should add a function to
> .vimrc. I did that and added:
You can also move the whole function into a script¹, (any filename
with the extension .vim will do) and move it into your plugin
directory (which should be $HOME/.vim/plugin on all Systems except
Windows, where you would drop it into $HOME/vimfiles/plugin, create
directories, that do not yet exist).
I like this approach, since it lets me create a whole bunch of
separate scripts with distinct functionality and allows me to easily
adjust or disable those scripts (e.g. simply removing the .vim
extension from the script) and keeps my .vimrc simpler.
But note, that these plugins will always be loaded. You can also
create filetype specific plugins. Read more about global-plugins at
:h add-global-plugin
and for creating filetype specific plugins at
:h add-filetype-plugin
> function! Archive_all_modified_buffers()
> set hidden
> let archive=[]
> bufdo if &modified | call add(archive, shellescape(expand("%"),1))| endif
>
> if len(archive) > 0
> exe "!tar -cvjf archive.tar.bz2 " . join(archive, " ")
> endif
> endfunction
>
> Then I called it (call Archive_all...). It seemed to work on all the
> (modified?) buffers but I didn't see the archive.tar.bz2 file being
> created. Nor could I find it in my account.
Check your path (:pwd). This shows in which path you executed the
command and where the external command saved your data. Nevertheless,
you'll probably want to add some error-checking, specifying the output
directory and filename and something like this.
regards,
Christian
__
¹) adding enhancements, such as user-commands (:h user-commands) or
adding a map to execute this function more easier.
Liebe Grüße
Christian
--
:wq!
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---