" -*- vim -*- " URL: http://sites.netscape.net/BBenjiF/vim/ncftp.html " FILE: "D:\vim\ncftp.vim" " UPLOAD: URL="ftp://siteftp.netscape.net/vim/ncftp.vim" USER="BBenjiF" " LAST MODIFICATION: "Fri, 24 Nov 2000 10:26:13 Eastern Standard Time ()" " (C) 2000 by Benji Fisher, " $Id:$ command! -nargs=* Nw call NCFTPwrite() fun! NCFTPwrite(...) " First, try to set url and user from the file. let mark = line(".") . "normal!" . virtcol(".") . "|" normal H let top_of_screen = line(".") $put='UPLOAD: URL=\"\" USER=\"\"' 0/UPLOAD:\s*URL=".*"/ let url = substitute(getline("."), '^.\{-}URL="\(.\{-}\)".*$', '\1', "") 0/UPLOAD:.*USER=".*"/ let user = substitute(getline("."), '^.\{-}USER="\(.\{-}\)".*$', '\1', "") undo " set nomodified execute top_of_screen normal zt execute mark " Next, check the arguments. if a:0 && a:1 != "" let url = a:1 if a:0 > 1 let user = a:2 endif endif " If neither of the above worked, try buffer arguments or user input. if url == "" if exists("b:NCFTP_url") let url = b:NCFTP_url else let url = input("Enter URL: ") endif endif if user == "" if exists("b:NCFTP_user") let user = b:NCFTP_user else let user = input("Enter USER: ") endif endif " Save for next time and extract host, dir from url. let b:NCFTP_url = url let b:NCFTP_user = user let host = substitute(url, '.\{-}ftp://\(.\{-}\)/.*', '\1', "") let dir = substitute(url, '.\{-}ftp://.\{-}/\(.*\)/.*', '\1', "") execute "!ncftpput -u " . user . " " . host . " " . dir . " " . expand("%:p") endfun " vim:set sts=2 sw=2: