Coder Social home page Coder Social logo

vim-sync's Introduction

vim-sync

Automatic sync local and remote file in vim

Installation

Install using bundle,vundle,pathogen or your favorite Vim package manager.

Requires

Asyncrun to upload asynchronously.

Usage

create a execute file called .sync in your project directory. e.g. /project_dir/ is your project dirctory and the execute file is /project_dir/.sync. how to write execute file see "some execute config" section.

<leader>su
Upload current buffer file, it will execute the command: project_dir/.sync upload current_buffer_fold current_file_name

<leader>sd
Download current buffer file, it will execute the command: project_dir/.sync download current_buffer_fold current_file_name

some execute config

  • rsync:
#!/bin/sh
if [ "upload" == $1 ];then
    rsync -azcuv -e "/bin/ssh -p36000 -q" `dirname $0`/$2/$3 login_name@remote_host:/remote_path/$2/$3
elif [ 'download' == $1 ];then
    rsync -azcuv -e "/bin/ssh -p36000 -q" login_name@remote_host:/remote_path/$2/$3 `dirname $0`/$2/$3
fi
  • sftp:
#!/bin/sh
if [ "upload" == $1 ];then
    expect -c <<'END_EXPECT'
	set timeout -1
	spawn sftp [email protected]
	expect "[Pp]assword:"
	send "login_password\r"
	expect "sftp>"
	send "put `dirname $0`/$2/$3 /remote_path/$2/$3\r"
	expect "%100"
	send "quit\r"
	expect eof
	END_EXPECT
elif [ 'download' == $1 ];then
    expect -c <<'END_EXPECT'
	set timeout -1
	spawn sftp [email protected]
	expect "[Pp]assword:"
	send "login_password\r"
	expect "sftp>"
	send "get /remote_path/$2/$3 `dirname $0`/$2/$3 \r"
	expect "%100"
	send "quit\r"
	expect eof
	END_EXPECT
fi
  • ftp:
#!/bin/sh
if [ "upload" == $1 ];then
  ncftpput -m -u login_name -p login_password -P 21 remote_host remote_path/$2 `dirname $0`/$2/$3
elif [ 'download' == $1 ];then
  ncftpget -u login_name -p login_password -P 21 remote_host `dirname $0`/$2 remote_path/$2/$3
fi
  • scp:

    referred to rsync

  • ...

Configuration

  • g:sync_exe_filenames (default: '.sync;')

Defines the filenames of the executable file to use to synchronize your sources.

This file will be searched from the directory of the file to synchronized. For example, when editing a symlink and g:sync_push_symlink_too is enabled the target will first be synchronized and the file will be searched from the target directory. Then the symlink will be synchronized and the file will be searched from the symlink directory.

You can prodive multiple filenames, separate with a ",".

To look backward in the directory tree add ";" at the end of the filname.

Example :

let g:sync_exe_filenames = '.sync;' " Looks backward for a file named ".sync"

let g:sync_exe_filenames = '.sync;,.sync.sh; " Looks backward for a file named ".sync". If not found then looks backward for a file named ".sync.sh"'

  • g:sync_push_symlink_too (default: 0)

When editing a symlink, allows to synchronized the symlink itself. If disabled, only the target is synchronized.

Might be usefull is you use a lot of symlinks and don't want to have to push them manually to the remote.

  • g:sync_async_upload (default: 1)

Defines if the upload should be asynchronous. Requires the [Asyncryn] plugin.

Alias

If you want to another command, write following like.

Ctrl+u nnoremap <C-U> <ESC>:call SyncUploadFile()<CR>

Ctrl+d nnoremap <C-D> <ESC>:call SyncDownloadFile()<CR>

  • if you want to auto upload/download file where save/open file, write these code in you .emacs config file:

      autocmd BufWritePost * :call SyncUploadFile()
      autocmd BufReadPre * :call SyncDownloadFile()
    

vim-sync's People

Contributors

eshion avatar camilledejoye avatar tuch avatar ruchee avatar w169q169 avatar shpontex avatar

Watchers

Reyzal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.