PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

VIM: Automatically insert words into CtrlP

Note: This article was originally published at Planet PHP on 7 December 2012.
Planet PHP

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 :CtrlPw

If you want to insert a selected line straight into CtrlP you can do that asAwell:

1vmap lw y:CtrlPc

Pressing 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. PrettyAneat!