vim

vim에서 사용하는 FTP 기능

토픽 vim

 map <F5> :call FTPW()<CR>

 

function! FTPW()

"Define Site Information-------------------------------

let SD_1_ID = 'USER_ID1'

"let SD_1_PASSWD = 'PASSWORD1'

let SD_1_HOSTNAME = 'HOSTNAME.COM'

let SD_1_LOCALPATH = 'D:\wwwroot'

"let SD_1_PORT = '21'

"let SD_1_REMOTEPATH = ''

 

 

 

let SD_2_ID = 'USER_ID2'

let SD_2_PASSWD = 'PASSWORD2'

let SD_2_HOSTNAME = 'OTHER.HOSTNAME.COM'

let SD_2_LOCALPATH = 'D:\otherwwwroot\public_html'

let SD_2_PORT = '2121'

let SD_2_REMOTEPATH = 'public_html'

 

let COUNT = 2

"End Of Information------------------------------------

 

 

let current = 1

let found = 0

while current <= COUNT

exe "let localpath = SD_".current."_LOCALPATH"

 

let localpath = localpath.'\'

let lb_len = strlen(localpath)

let curdir = strpart(expand("%:p"), 0, lb_len)

 

if curdir == localpath

exe "let g:netrw_uid = SD_".current."_ID"

exe "let hostname = SD_".current."_HOSTNAME"

 

if exists("SD_".current."_PASSWD") 

exe "let g:netrw_passwd = SD_".current."_PASSWD"

else

let g:netrw_passwd = inputsecret("Enter Password: ")

endif

 

if exists("SD_".current."_REMOTEPATH")

exe "let remotepath = SD_".current."_REMOTEPATH"

endif

 

if exists("SD_".current."_PORT")

exe "let port = SD_".current."_PORT"

endif

 

let found = 1

break

endif

 

let current = current + 1

endwhile

 

if found

let filepath = strpart(expand("%:p"), lb_len)

let filepath = substitute(filepath, '\', '/', 'g')

 

if exists("port")

let execmd = "w ftp://".g:netrw_uid.":".port."@".hostname."/"

else

let execmd = "w ftp://".g:netrw_uid."@".hostname."/"

endif

 

if exists("remotepath")

if remotepath != ''

let execmd = execmd.remotepath."/"

endif

endif

 

let execmd = execmd.filepath

 

exe execmd

 

else

echo "Base Directory Not Found"

endif

 

endfunction

댓글

댓글 본문