"define :Tidy command to run perltidy on visual selection || entire buffer" command! -range=% -nargs=* Tidy ,!perltidy "run :Tidy on entire buffer and return cursor to (approximate) original position" fun! DoTidy() let l = line(".") let c = col(".") :Tidy call cursor(l, c) endfun "shortcut for normal mode to run on entire buffer then return to current line" noremap :call DoTidy() "shortcut for visual mode to run on the the current visual selection" vnoremap :Tidy