m (use pre instead of code tags) |
("^W" wasn't a mistake, it was actually needed to actually run the function when using the map. But keycode syntax is better.) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 17: | Line 17: | ||
</pre> |
</pre> |
||
− | From the command line: |
+ | From the command line use: |
− | |||
<pre>vimdiff -c 'set diffopt+=iwhite' ...</pre> |
<pre>vimdiff -c 'set diffopt+=iwhite' ...</pre> |
||
+ | To have vimdiff ignore whitespace while normal vim doesn't, simply put this into your .vimrc: |
||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
− | ==Comments== |
||
− | Combining this with a note from the |
||
− | [http://vimdoc.sourceforge.net/htmldoc/diff.html generic vim help], this can be |
||
− | done in .vimrc using |
||
<pre> |
<pre> |
||
if &diff |
if &diff |
||
⚫ | |||
set diffopt+=iwhite |
set diffopt+=iwhite |
||
− | else |
||
⚫ | |||
endif |
endif |
||
</pre> |
</pre> |
||
+ | |||
+ | To have a toggle way to ignore / not ignore whitespaces in vimdiff, put this into your .vimrc: |
||
+ | <source lang='vim'> |
||
+ | if &diff |
||
+ | map gs :call IwhiteToggle()<CR> |
||
+ | function! IwhiteToggle() |
||
+ | if &diffopt =~ 'iwhite' |
||
+ | set diffopt-=iwhite |
||
+ | else |
||
+ | set diffopt+=iwhite |
||
+ | endif |
||
+ | endfunction |
||
+ | endif |
||
+ | </source> |
||
+ | |||
⚫ | |||
⚫ | |||
⚫ |
Latest revision as of 16:00, 5 June 2018
Tip 1294 Printable Monobook Previous Next
created 2006 · complexity basic · author vagusri · version 5.7
I had been searching for a way to ignore white spaces while using vimdiff. Unfortunately, vimdiff -h
yields the generic Vim help. I finally found that including the following line in vimrc solves the problem.
set diffopt+=iwhite
From the command line use:
vimdiff -c 'set diffopt+=iwhite' ...
To have vimdiff ignore whitespace while normal vim doesn't, simply put this into your .vimrc:
if &diff " diff mode set diffopt+=iwhite endif
To have a toggle way to ignore / not ignore whitespaces in vimdiff, put this into your .vimrc:
if &diff
map gs :call IwhiteToggle()<CR>
function! IwhiteToggle()
if &diffopt =~ 'iwhite'
set diffopt-=iwhite
else
set diffopt+=iwhite
endif
endfunction
endif