Re: vim replace a string when a change occurred in another place

2015-06-24 Thread KF
On Tuesday, June 23, 2015 at 6:52:54 PM UTC+8, Rudra Banerjee wrote: > Hi, > > Say, I have a file: > Program foo > > End Program foo > > Is it possible that if I change the word "foo" in the first line to "bar" > (which may not be the first line of the file), the last line's "foo" will > also

Re: vim replace a string when a change occurred in another place

2015-06-24 Thread Erik Christiansen
On 23.06.15 23:56, Rudra Banerjee wrote: > Erik, > Thanks for you commentbut it is solved. Now, another important > thinghow to invoke it! Is it possible to have something like this: > > if (getline(".")) startswith "Program" au CursorMovedI call EdName() > > i.e. calling a autocmd condit

Re: vim replace a string when a change occurred in another place

2015-06-23 Thread Rudra Banerjee
Erik, Thanks for you commentbut it is solved. Now, another important thinghow to invoke it! Is it possible to have something like this: if (getline(".")) startswith "Program" au CursorMovedI call EdName() i.e. calling a autocmd conditionally possible? -- -- You received this message

Re: vim replace a string when a change occurred in another place

2015-06-23 Thread Erik Christiansen
On 23.06.15 08:00, Rudra Banerjee wrote: > function! Edname() > python< import vim > import fileinput > with open("i.f90") as inp: > for line in inp: > if line.startswith("Program"): > var = line.rsplit(' ', 1)[-1].strip() > if line.startswith("End Program"): >

Re: vim replace a string when a change occurred in another place

2015-06-23 Thread Rudra Banerjee
Erik, Thanks for your detailed answer. I have choose python (so that it can be called from vim's ftplugin.) I have checked the standalone python code, which works. But, I put the python code inside vim as: function! Edname() python

Re: vim replace a string when a change occurred in another place

2015-06-23 Thread Erik Christiansen
On 23.06.15 03:52, Rudra Banerjee wrote: > Say, I have a file: > Program bar > > End Program bar > > Is it possible that if I change the word "foo" in the first line to > "bar" (which may not be the first line of the file), the last line's > "foo" will also be changed to "bar" automatically? >F

vim replace a string when a change occurred in another place

2015-06-23 Thread Rudra Banerjee
Hi, Say, I have a file: Program foo End Program foo Is it possible that if I change the word "foo" in the first line to "bar" (which may not be the first line of the file), the last line's "foo" will also be changed to "bar" automatically? -- -- You received this message from the "vim_use"