The default behavior of the K command is to lookup the keyword under the cursor using man. This is handy at times, but it's not very useful when I spend 90% of my day writing PHP code. Vim's online help mentions that you can set keywordprg to an alternative program, so I did the following.
set keywordprg=/home/travis/pdoc
Where pdoc is the following shell script:
#!/bin/sh
firefox http://us3.php.net/manual/en/function.$1.php
Now I can move the cursor over a builtin function, hit K, and firefox will open to the appropriate documentation. To keep things strictly textual, you could use lynx (or links) in lieu of firefox.
For ruby code, I like to do the following:
set keywordprg=ri
For Perl:
set keywordprg=perldoc\ -tf
Showing posts with label cursor. Show all posts
Showing posts with label cursor. Show all posts
Friday, August 15, 2008
Thursday, May 15, 2008
Start of Match
When searching or writing macros in Vim, it's sometimes helpful to have a search position your cursor at the end of the matching term rather than the beginning. You can use the start of match atom to accomplish this.
/some term\zs
This would match "some term" and position your cursor at the end of the match. See (help :regexp) for other atoms and general regexp goodness.
Thanks to Chris Sutter for contributing this tip.
/some term\zs
This would match "some term" and position your cursor at the end of the match. See (help :regexp) for other atoms and general regexp goodness.
Thanks to Chris Sutter for contributing this tip.
Wednesday, April 30, 2008
Character Above, Below
If you're in insert mode, and you want to insert the character above the cursor, hit ctrl-y. To insert a character below the cursor, hit ctrl-e. Alternatively, if you want to grab entire words above and below, you can use the following mappings (which use text objects).
inoremap <C-Y> <Esc>klyiWjpa
inoremap <C-E> <Esc>jlyiWkPa
inoremap <C-Y> <Esc>klyiWjpa
inoremap <C-E> <Esc>jlyiWkPa
Thursday, December 6, 2007
Value Under Cursor
Sometimes I run into funky characters in files I'm editing. Sometimes I want to know what they are. Vim makes this easy. Put your cursor on the character you want to examine and type ga in normal mode. You can also use the ex command :ascii if you prefer.
Friday, November 16, 2007
GOTO File Under Cursor (not harmful)
If you're editing a file and have your cursor positioned on a file you would like to open with Vim, press `gf' from normal mode, and it will open in the same window. Ctrl-w f will open it in a new window, and Ctrl-w gf will open it in a new tab.
Subscribe to:
Posts (Atom)