Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When editing PL/SQL files I look for a way to open a file based on a word under cursor and preferable jump to a certain positon.

Files are all located in same directory.

Example file app_dummy.pkb contains:

  app_package.procedure1( i_input1 => 'mmm' );
  when others then raise...

Looking for a way to open app_package.pkb (extension is known) in another buffer and move cursor to procedure1.

I know there is ctags but not all systems I work on have that available.

share|improve this question
please accept the answer by clicking on the checkbox. This marks the question as answered & prevents it from bumping up – Sathya Aug 3 '11 at 4:51
nmap <F2> yiw2w:split +/<C-R><C-W> <C-R>0.pkb<CR>

With the cursor over the package name, pressing F2 will open a new buffer containing a file named <package>.pkb and will search for the string following the . after the package name.

yiw - yanks the word under the cursor (the package name)
2w - moves the cursor two words to the right (where . counts as a word)
:split - splits the window
+ - introduces a command to be executed in the new window
/ - begins a search
<C-R><C-W> - inserts the word under the cursor (the procedure name)
<C-R>0 - inserts the contents of register 0 (zero), the yank register
.pkb - adds the file suffix
<CR> - terminates and executes the :split command

Those characters are to by typed literally. For example, <C-R> is the five-character sequence < C - R >. They are not to be replaced by a Ctrl-R when you type them.


:help :split_f
:help c_CTRL-R
:help registers
share|improve this answer
Thank you very much. Works perfectly as long as I don't forget to set correct working directory :) – Pigna Jul 28 '11 at 18:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .