VIM: Automatically insert words into CtrlP
Note: This article was originally published at Planet PHP
on 6 December 2012.
If you use the excellent CtrlP plugin for VIM here's a quick tip. You can automatically insert the word under your cursor into CtrlP. This is super handy especially for PHP development where class names often map to file names 1:1. To do this we need to create a mapping that will bring up CtrlP, press and then press w:
1nmap lw :CtrlPwIf you want to insert a selected line straight into CtrlP you can do that asA well:
1vmap lw y:CtrlPcPressing lw in normal mode should now open CtrlP, insert and search for the word under your cursor. When in visual mode it should insert and search for the selected text. PrettyA neat!


