Hi,
Yesterday I found g? command which is used to do rot13 encoding. If we want to encode all buffers we should go to every buffer and do "ggVg?G", I wonder if there is a function which can do rot13 encoding? So we just need to call the function and don't need to switch to every buffer and change cursor position. Any help would be appreciated! Best regards, ????????????????Bruce Who ????????????????????2005-05-24 |
On Tuesday 24 May 2005 03:01, Bruce Who wrote:
> Hi, > > Yesterday I found g? command which is used to do rot13 encoding. If we > want to encode all buffers we should go to every buffer and do "ggVg?G", I > wonder if there is a function which can do rot13 encoding? So we just need > to call the function and don't need to switch to every buffer and change > cursor position. :bufdo normal ggg?G :help :bufdo :help :normal -- Erlend Hamberg [hidden email] |
In reply to this post by Bruce Who
Hi, Erlend:
I knew we can use g? in a function or in a command like this: :bufdo :normal ggVg?G but, the disadvantage of this normal mode command is that it changes the cursor position. After the command is called, the cursor position is at the end of every buffer. I want to keep the cursor position, so I think a function may solve the problem. Any ideas? ======= 2005-05-24 09:04:13 Erlend Hamberg wrote: ======= >On Tuesday 24 May 2005 03:01, Bruce Who wrote: >> Hi, >> >> Yesterday I found g? command which is used to do rot13 encoding. If we >> want to encode all buffers we should go to every buffer and do "ggVg?G", I >> wonder if there is a function which can do rot13 encoding? So we just need >> to call the function and don't need to switch to every buffer and change >> cursor position. > >:bufdo normal ggg?G > >:help :bufdo >:help :normal > >-- >Erlend Hamberg >[hidden email] >. = = = = = = = = = = = = = = = = = = = = Best regards, ????????????????Bruce Who ????????????????????2005-05-24 |
Bruce Who wrote:
> Hi, Erlend: > > I knew we can use g? in a function or in a command like this: > > :bufdo :normal ggVg?G > > but, the disadvantage of this normal mode command is that it changes the cursor position. After the command is called, the cursor position is at the end of every buffer. I want to keep the cursor position, so I think a function may solve the problem. Any ideas? > function! Rot13Encode() range let l = line(".") let c = col(".") exe "normal " . a:firstline . "gg" normal V exe "normal " . a:lastline . "gg" normal g? call cursor(l,c) endfunction " ... etc. ... bufdo 1,$call Rot13Encode() Best regards, Tony. |
In reply to this post by Bruce Who
Hi, Tony:
Thanks. That's what I need! ======= 2005-05-24 10:31:42 A. J. Mechelynck wrote: ======= >Bruce Who wrote: >> Hi, Erlend: >> >> I knew we can use g? in a function or in a command like this: >> >> :bufdo :normal ggVg?G >> >> but, the disadvantage of this normal mode command is that it changes the cursor position. After the command is called, the cursor position is at the end of every buffer. I want to keep the cursor position, so I think a function may solve the problem. Any ideas? >> > > function! Rot13Encode() range > let l = line(".") > let c = col(".") > exe "normal " . a:firstline . "gg" > normal V > exe "normal " . a:lastline . "gg" > normal g? > call cursor(l,c) > endfunction > > " ... etc. ... > > bufdo 1,$call Rot13Encode() > > >Best regards, >Tony. > >. = = = = = = = = = = = = = = = = = = = = Best regards, ????????????????Bruce Who ????????????????????2005-05-24 |
In reply to this post by Bruce Who
On Tue, May 24, 2005 at 09:51:54AM +0800, Bruce Who wrote:
> Hi, Erlend: > > I knew we can use g? in a function or in a command like this: > > :bufdo :normal ggVg?G > > but, the disadvantage of this normal mode command is that it > changes the cursor position. After the command is called, the > cursor position is at the end of every buffer. I want to keep the > cursor position, so I think a function may solve the problem. Any > ideas? let curcol = col('.') let currow = row('.') normal ggg?G call cursor(currow, curcol) endfun :bufdo call KeepCursorRot13() :help col() :help row() :help cursor() HTH, James -- GPG Key: 1024D/61326D40 2003-09-02 James Vega <[hidden email]> |
Free forum by Nabble | Edit this page |