Home > Linux > Vim Tip of the Week : SHIFT-K

Vim Tip of the Week : SHIFT-K

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.

Categories: Linux Tags:
  1. LaserJock
    July 20th, 2007 at 20:29 | #1

    This one rocks. I’m still amazed at how powerful vim is while still being so “light”.

  2. tomchuk
    July 20th, 2007 at 20:31 | #2

    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’

  3. July 20th, 2007 at 20:41 | #3

    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.

  4. July 21st, 2007 at 06:07 | #4

    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.

  5. mlissner
    July 21st, 2007 at 12:06 | #5

    Keep up the vim tips!

  1. July 20th, 2007 at 22:55 | #1
  2. August 3rd, 2007 at 08:55 | #2