Ole Morten Halvorsen

Dec. 6, 2012
VIM: Automatically insert words into CtrlP

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 <C-\> and then press w:

nmap <leader>lw :CtrlP<CR><C-\>w

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

vmap <leader>lw y:CtrlP<CR><C-\>c


As an example, in the above image the cursor is placed oneZINI. Pressing <leader>lw in will open CtrlP, insert and search for eZINI.

CtrlP 2

Pretty neat!

Leave a comment

Commenting has been disabled. This entry was posted more than 2 weeks ago.

Created by Ole Morten Halvorsen.   Powered by Django.