Editing Comparing files
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 45: | Line 45: | ||
# Add following lines to your <code>vifmrc</code>:<code> | # Add following lines to your <code>vifmrc</code>:<code> | ||
command! cmpinternal compare-cmd %a %S | command! cmpinternal compare-cmd %a %S | ||
− | command! cmp : if expand(' | + | command! cmp : if expand('%c') == expand('%f') |
− | \ | echo expand('Comparing | + | \ | echo expand('Comparing %"c and %"C:t ...') |
\ | cmpinternal %c %C | \ | cmpinternal %c %C | ||
\ | else | \ | else | ||
− | \ | echo expand('Comparing files: | + | \ | echo expand('Comparing files: %"f ...') |
\ | cmpinternal %f | \ | cmpinternal %f | ||
\ | endif | \ | endif | ||
Line 56: | Line 56: | ||
Explanation of key parts: | Explanation of key parts: | ||
* <code>cmpinternal</code> — a trick to invoke external command. Calling <code>execute "!compare-cmd ... %S"</code> reparses command-line which leads to loosing results of command execution (they are overwritten by execution of <code>if-else-endif</code> block). | * <code>cmpinternal</code> — a trick to invoke external command. Calling <code>execute "!compare-cmd ... %S"</code> reparses command-line which leads to loosing results of command execution (they are overwritten by execution of <code>if-else-endif</code> block). | ||
− | + | * <code>expand('%c') == expand('%f')</code> — check whether only one file is selected in current pane. | |
− | * <code>expand(' | ||
== Usage == | == Usage == |