VIM Tricks

less than 1 minute read

I may be stuck in the past, or like punishment, but my editor of choice is still VIM.  However, certain tricks seem to be hard to find on Google searches, so I’m going to compile them here:

  • Creating custom commands and keyboard mappings are easy in VIM.  To create a custom command, list the command in the .vimrc file.  The % character includes the current buffer’s filename in the shell command.

    command CommandName execute "!shellcommand %"

    This command can be run in VIM using the standard :CommandName convention. To map this new command to a keyboard shortcut, use the map command in the .vimrc file.

    map <F5> :CommandName<CR>