views:

42

answers:

1

Hi All, This is what I want to do using GVIM 7.3:

  1. open a file in new tab (first tab)
  2. get all lines which contain a pattern -> insert them to a register/clipboard
  3. open a new tab (second tab)
  4. paste the code from clipboard
  5. do some regex replace process in the second tab.

I can manually execute commands one by one successfully.

I even can do commands in sequence using this sample :

:let @b="This Value should be pasted in second tab"  | :set dir=$TEMP | :tabe tabname | "bp | :%s/tab/tab and replaced in second tab/gi

but when I record them into a macro; The macro stops at step 3

Is there special technique dealing with function/macro that access multiple tabs

Thank you.

this is the commands sample

    :let @b="This Value should be pasted in second tab" 
    :set dir=$TEMP
    ":tabe tabName
    "bp 
:%s/tab/tab and replaced in second tab/gi 
A: 

You have a wrong syntax on your first line: Ex commands should not start with :: you use : to open command line, it is not an Ex command designator. So, all what "bp does in this sequence is commenting the whole line starting with ". If you want to execute normal command "bp, use execute 'normal! "bp', but you can also paste with put b. Function that can do what you want (to be put in ~/.vimrc):

function! FindToTab(regex)
    let @b=""
    execute 'g/'.escape(a:regex, '/').'/.yank B'
    set dir=$TEMP
    tabe tabName
    put b
    %s/tab/tab and replaced in second tab/gi
endfunction
noremap <special> ,r :<C-u>call FindToTab(input("What to find? /", @/))<CR>
ZyX
Wow, Thanks for your quick help. I will try your answer before marking as answer
kite