Home

Awesome

🧰 vim-dirvish-dovish

The file manipulation commands for vim-dirvish that you've always wanted

Have only tested on MacOS and Neovim, but it should work with Vim.

Installation & Requirements

You'll need:

Then install with your favorite package manager:

Plug 'roginfarrer/vim-dirvish-dovish', {'branch': 'main'}

Mappings

FunctionDefaultKey
Create filea<Plug>(dovish_create_file)
Create directoryA<Plug>(dovish_create_directory)
Delete under cursordd<Plug>(dovish_delete)
Rename under cursorr<Plug>(dovish_rename)
Yank under cursor (or visual selection)yy<Plug>(dovish_yank)
Copy file to current directorypp<Plug>(dovish_copy)
Move file to current directoryPP<Plug>(dovish_move)

You can unmap all of the maps above and set your own (mine are below). Add this to ftplugin/dirvish.vim:

" unmap all default mappings
let g:dirvish_dovish_map_keys = 0

" unmap dirvish default
unmap <buffer> p

" Your preferred mappings
nmap <silent><buffer> i <Plug>(dovish_create_file)
nmap <silent><buffer> I <Plug>(dovish_create_directory)
nmap <silent><buffer> dd <Plug>(dovish_delete)
nmap <silent><buffer> r <Plug>(dovish_rename)
nmap <silent><buffer> yy <Plug>(dovish_yank)
xmap <silent><buffer> yy <Plug>(dovish_yank)
nmap <silent><buffer> p <Plug>(dovish_copy)
nmap <silent><buffer> P <Plug>(dovish_move)

Customize Commands

Most file operations can be customized. Below are the defaults:

" Used for <Plug>(dovish_yank)
function! g:DovishCopyFile(target, destination) abort
  return 'cp ' . a:target . ' ' . a:destination
endfunction

" Used for <Plug>(dovish_yank)
function! g:DovishCopyDirectory(target, destination) abort
  return 'cp -r' . a:target . ' ' . a:destination
endfunction

" Used for <Plug>(dovish_move)
function! g:DovishMove(target, destination) abort
  return 'mv ' . a:target . ' ' . a:destination
endfunction

" Used for <Plug>(dovish_delete)
function! g:DovishDelete(target) abort
  return 'trash ' . a:target
endfunction

" Used for <Plug>(dovish_rename)
function! g:DovishRename(target, destination) abort
  return 'mv ' . a:target . ' ' . a:destination
endfunction

Credit

Big shout out to Melandel for laying the foundation for this plugin!