sponsor Vim development Vim logo Vim Book Ad

Alternate workspace : Switch or watch diff between alternate files from child and parent workspaces

 script karma  Rating 24/6, Downloaded by 1106  Comments, bugs, improvements  Vim wiki

created by
Mykola Golubyev
 
script type
utility
 
description
This script provide a way to quickly switch between files from different workspaces (Child and Parent). And to see difference between them.

Set variable g:aw_child_path and g:aw_parent_path to work with this script.

Example of vimrc:

   let g:aw_child_path = '/home/ni/branch'
   let g:aw_parent_path = '/project/'
   let g:aw_stop_word = 'src'

   nnoremap \wd :AWDiffMirror<CR>
   nnoremap \we :AWEditMirror<CR>

EDIT MIRROR

Suppose you have two files in different workspaces.
You edit now file from child workspace.

you are at line 100
in that line is text 'int main()'

in alternate file there is line 'int main()' too but in line 200

after command :AWEditMirrorFile you will be at line 200 in alternate file
It is very useful.

if there is now such line in alternate file you'll be at line 100.

SET WORKSPACES

Use AWSetChild and AWSetParent commands to set workspaces directories (thanks to Sergey Popov).

Use AWAutoSetChild and AWAutoSetParent commands - this commands will create child and parent path form current file name
example:
    let g:aw_stop_word = 'src'
    current file name = '/home/me/project/src/..../.../1.cpp'
    after execution of AWAutoSetChild aw_child_path will be '/home/me/project/'

:AWEditMirrorFile - edit alternate file
:AWDiffMirrorFile - diff current and alternate file
 
install details
Put alternate_workspace.vim in plugin directory
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
alternate_workspace.vim 2.0 2006-12-19 6.0 Mykola Golubyev AWEditMirrorFile command not only open alternate file but moves to position where is same line (current line) is present.
You can easily change workspaces by new commands:
:AWAutoSetChild
:AWAutoSetParent
Example:
if you have current file name "/home/me/project/src/...../.cpp"
you can set variable g:aw_stop_word = "src" and after execution of command :AWAutoSetChild
child path will be "/home/me/project"

Removed mappings for EditMirrorFile and DiffMirrorFile (
Add
nnoremap key1 :AWEditMirrorFile<CR>
nnoremap key2 :AWDiffMirrorFile<CR>
...
alternate_workspace.vim 1.1 2006-09-26 6.0 Mykola Golubyev Added AWSetChild and AWSetParent commands.
alternate_workspace.vim 1 2006-09-25 6.0 Mykola Golubyev Initial upload
ip used for rating: 18.118.227.69

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github