Well you asked for it. Last week I did the first vim tip of the week and it looks like you all want more. I got another goodie today that you might enjoy. How many of you know what SHIFT-K does in command mode? No, don’t go look it up. Do you know right now? If not keep reading. If so, I’m impressed.
Instead of just telling you what it does I want you to give it a try for yourself (no better way to learn than to do, right?). Follow the below instructions and see if you can figure out what it does. First person to figure it out and comment with the answer wins!
Ready, Set, Go!
Open up a new file with vim:
vim file1
switch to insert mode (i,I,a,A,o,O, etc).
type a few linux commands into a new line (any command you want):
vim awk man aptitude
switch back to command mode (esc)
put your cursor on any of the commands and press SHIFT-K.
Pretty slick, particularly when trying to decipher shell scripts if you’re unfamiliar with the commands, or reading documentation that refers to related apps!
…so, what does it do? Enjoy.. and be back next week for another tip! Thanks Dax for pointing this out to me.
This one rocks. I’m still amazed at how powerful vim is while still being so “light”.
You can also set keyword programs in your vimrc. For instance, for php functions:
In your ~/.vimrc
autocmd FileType php set keywordprg=~/.vim/php_doc
And ~/.vim/php_doc:
#!/bin/sh
FN=`echo $1 | sed ‘s/_/-/g’`
echo ********************** $FN **********************
lynx -dump -nolist http://www.php.net/manual/en/print/function.$FN.php | sed -n /^$1/,/^.*User\ Contributed\ Notes/p | grep -v ‘User\ Contributed\ Notes’
May I suggest you look at http://www.vim.org/scripts/script.php?script_id=489
It overrides shift-K and allows you to open man pages in a split similar to the :help command. Very pretty and hyperlinkable.
Happy vimming.
Pingback: University Update - Linux - Vim Tip of the Week : SHIFT-K
Good tip and a new one for me, even though I think of myself as a power vim users. I keep trying “prettier” editors and keep coming back go vim for the functionality.
Keep up the vim tips!
Pingback: Vim Tip of the Week - Encryption : Aug 3, 2007 : Ubuntu Tutorials : Breezy - Dapper - Edgy - Feisty