Monday, June 9, 2014

Re: vimdiff noob question


set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '"' . $VIMRUNTIME . '\diff"'
let eq = '""'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction

On Monday, June 9, 2014 12:01:34 PM UTC-6, Ben Fritz wrote:
> On Monday, June 9, 2014 11:59:04 AM UTC-5, wolfv wrote:
> >
> > Thanks for looking into this some more.
> > I can open and edit vim files as usual when not in diff mode.
>
> Including the files you're diffing? And they're not empty when you edit them outside of diff mode?
>
> > a.txt and b.txt files are in C:\Users\wolf\Documents\
> > What does that mean? - "using the real System32 folder for 32-bit processes"
>
> Windows' "virtual store" means that if you try to create a file in certain protected system folders, you can get some sort of shadow copy instead. I don't remember the details. Maybe this helps: http://www.sevenforums.com/general-discussion/222389-what-virtual-store-folder.html
>
> Windows' "WOW64" redirection means that since Vim is 32-bit, if it tries to access the C:\Windows\System32 directory on a 64-bit system (containing 64-bit apps) it will instead get redirected to C:\windows\SysWOW64.
>
> Both of these scenarios can make Vim edit a file in a different location than you intended.
>
> But it looks like you're editing in your user directory and these should not affect you.
>
>
> Have you tried disabling all plugins and using a stripped-down .vimrc, containing only the diff setup? The diffexpr should not be deleting all file contents...

Here is a detailed play-by-play of me opening files in vim (screen shots are attached):

I open files a.txt and b.txt in vim (non-diff mode).
Then I enter this in Command Prompt:
vim -d a.txt b.txt
Upon hitting enter, a warning pops up:
W11: Warning: File "a.txt" has changed since editing started
See ":help W11" for more info.
[OK] [Load File]
I click the "Load File" button, and file a.txt is empty in the vim non-diff mode.
Similar for file b.txt.
The files are also empty in vimdiff.

I tried to disable all plugins with the --no-plugin switch when launching Vim, but a Message said:
VIM - ViIMproved 7.4 (2013 Aug 10, compiled Apr 11 2014 15:25:28)
Unknown option argument: "--no-plugin"
More into with: "vim -h"
How to disable all plugins except vimdiff?
The _vimrc is the default file that installed with vim (attached).

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: