Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

begin
  dbms_output.put_line('Example');
  app_package.procedure1( i_input1 => 'mmm' );
exception
  when others then raise...
end;

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
add comment

1 Answer

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.

See

: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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.