• how i use [wt] and [rt] to Copy-Paste text between two files (in Vim)

    From HenHanna@21:1/5 to All on Sat Mar 2 23:20:53 2024
    it used to be so easy to Copy-Paste text between two files with Control-C, Control-V.

    THEN, 2 or 3 years ago, when i started using a new ver. of Windows,
    i could no longer to this.


    So i've set up the following as a Work-around

    :ab wt w! ~/temp.vi
    :ab rt r ~/temp.vi

    So i can ..

    [1] from one file, do

    :.wt -- write 1 line to temp file
    :.,.+5 wt -- write 6 lines to temp file


    [2] optionally edit the temp file ---


    [3] from another file, do the following to read (in) the temp file

    :rt

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to HenHanna on Sun Mar 3 03:54:22 2024
    On 03.03.2024 00:20, HenHanna wrote:
    it used to be so easy to Copy-Paste text between two files with
    Control-C, Control-V.

    In Vim it's Y and P while in between switching to another file
    could be :n (if the file has been opened together with the first
    file) or :r filename (if you want to ad hoc open a file).


    THEN, 2 or 3 years ago, when i started using a new ver. of Windows,
    i could no longer to this.


    So i've set up the following as a Work-around

    :ab wt w! ~/temp.vi
    :ab rt r ~/temp.vi

    So i can ..

    [1] from one file, do

    :.wt -- write 1 line to temp file
    :.,.+5 wt -- write 6 lines to temp file


    [2] optionally edit the temp file ---

    [3] from another file, do the following to read (in) the temp file

    :rt

    In Vim you'd probably like to switch to a more Vim-like way of file
    processing. Open more than one file when calling Vim. Or in a Vim
    session use :split somefile to load another file (then you can
    toggle between your split parts of the window with Ctrl-W Ctrl-W,
    doing a Y on one side and P on the other side).
    Another option is to copy or append the yanked parts into a named
    register; for example

    "AY -- appends a line to the named register A
    42G -- move to another place (here e.g. to line 42)
    "A6Y -- appends 6 more lines to A
    ^W^W -- switch to the other split-window part (^W means Ctrl-W)
    -- or use :n if you want to switch to the next file opened
    "Ap -- insert the contents of A

    These are just examples. There's many ways you can do such things,
    depending on what fits best.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to HenHanna on Sun Mar 3 06:51:14 2024
    On Sat, 2 Mar 2024 23:20:53 +0000, HenHanna wrote:

    it used to be so easy to Copy-Paste text between two files with
    Control-C, Control-V.

    THEN, 2 or 3 years ago, when i started using a new ver. of
    Windows,
    i could no longer to this.

    Does Vim not do multi-file editing?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From G@21:1/5 to Lawrence D'Oliveiro on Sun Mar 3 09:10:32 2024
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sat, 2 Mar 2024 23:20:53 +0000, HenHanna wrote:

    it used to be so easy to Copy-Paste text between two files with
    Control-C, Control-V.

    THEN, 2 or 3 years ago, when i started using a new ver. of
    Windows,
    i could no longer to this.

    Does Vim not do multi-file editing?

    If you havo more then a few lines to copy or just check the differences
    between two similar files "vimdiff file1 file2" is quite useful. It has specific commands to copy from or to the other file.

    G

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anthony Howe@21:1/5 to HenHanna on Sun Mar 3 10:39:27 2024
    On 2024-03-02 18:20, HenHanna wrote:
    it used to be so easy to Copy-Paste text between two files with Control-C, Control-V.

    With Nvi you can edit two or more files at a time.

    :E edit another file (splits the screen)
    :N edit next file (split the screen) :P also
    ^W cycles through open files.

    AS I recall there are some commands or options to adjust the split screens, but never tried.

    So edit two ore more files at once; delete or yank lines from one, cycle to the next file, and paste.

    Don't recall if historical vi kept the named and numbered buffers between files,
    but you could try:

    "a}yy yank a paragraph into buffer a
    :e other edit other file
    p/P put (paste)
    :e% toggle back to previous file, ^^ also toggles files.

    So you can skip the need for a temporary file, unless you find that useful to hold onto.

    Also with Nvi there is unlimited undo/redo history:

    u toggle undo/redo last edit (historical vi)
    . repeat last, so if you undo, you can undo history (or reverse and redo).

    --
    Anthony C Howe
    achowe@snert.com BarricadeMX & Milters http://nanozen.snert.com/ http://software.snert.com/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Sun Mar 3 20:12:59 2024
    On 3 Mar 2024 09:10:32 GMT, G wrote:

    If you havo more then a few lines to copy or just check the differences between two similar files "vimdiff file1 file2" is quite useful. It has specific commands to copy from or to the other file.

    In normal editors, you use the same commands for cut/copy/paste as you
    would when editing a single file.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Anthony Howe on Mon Mar 4 08:22:22 2024
    On 03.03.2024 16:39, Anthony Howe wrote:

    Also with Nvi there is unlimited undo/redo history:

    u toggle undo/redo last edit (historical vi)
    . repeat last, so if you undo, you can undo history (or reverse and redo).

    In Vim it's 'u' for [multiple] undos and 'Ctrl-R' for redo.

    (There's also undo-trees, but I never used it.)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Mon Mar 4 08:16:34 2024
    On 03.03.2024 21:12, Lawrence D'Oliveiro wrote:

    In normal editors, you use the same commands for cut/copy/paste as you
    would when editing a single file.

    In Vi/Vim it's 'd', 'y', and, 'p' or 'P'.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From G@21:1/5 to Lawrence D'Oliveiro on Mon Mar 4 09:10:21 2024
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 3 Mar 2024 09:10:32 GMT, G wrote:

    If you havo more then a few lines to copy or just check the differences
    between two similar files "vimdiff file1 file2" is quite useful. It has
    specific commands to copy from or to the other file.

    In normal editors, you use the same commands for cut/copy/paste as you
    would when editing a single file.

    And in vimdiff you can use those command if you want (it is still vim after all), or use the specific command if you want do things faster.

    G

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Tue Mar 5 23:00:02 2024
    On 4 Mar 2024 09:10:21 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 3 Mar 2024 09:10:32 GMT, G wrote:

    If you havo more then a few lines to copy or just check the
    differences between two similar files "vimdiff file1 file2" is quite
    useful. It has specific commands to copy from or to the other file.

    In normal editors, you use the same commands for cut/copy/paste as you
    would when editing a single file.

    And in vimdiff you can use those command if you want (it is still vim
    after all), or use the specific command if you want do things faster.

    In Emacs, you can have two files open side by side. Or even more than two.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From HenHanna@21:1/5 to Lawrence D'Oliveiro on Wed Mar 6 03:38:22 2024
    Lawrence D'Oliveiro wrote:

    On 4 Mar 2024 09:10:21 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 3 Mar 2024 09:10:32 GMT, G wrote:

    If you havo more then a few lines to copy or just check the
    differences between two similar files "vimdiff file1 file2" is quite
    useful. It has specific commands to copy from or to the other file.

    In normal editors, you use the same commands for cut/copy/paste as you
    would when editing a single file.

    And in vimdiff you can use those command if you want (it is still vim
    after all), or use the specific command if you want do things faster.

    In Emacs, you can have two files open side by side. Or even more than two.



    in (the old Vi and) Vim , we can have 2 (or more) files open,
    but i don't like to do that because it's kinda confusing.





    _____________________________(a retro computer wisdom)


    In software systems, it is often the early bird that makes the worm.


    ---------- meaning, (the sleepy programmer) ...that introduces the BUG ?


    or ...... writes a computer virus ?????

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to HenHanna on Wed Mar 6 05:05:07 2024
    On Wed, 6 Mar 2024 03:38:22 +0000, HenHanna wrote:

    Lawrence D'Oliveiro wrote:

    On 4 Mar 2024 09:10:21 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    In Emacs, you can have two files open side by side. Or even more than
    two.

    in (the old Vi and) Vim , we can have 2 (or more) files open,
    but i don't like to do that because it's kinda confusing.

    Quite easy in Emacs. It also does multi-buffer editing, so you can have
    more files open than you have simultaneously visible. You can even have
    the same buffer visible in more than one frame/window, so you can see (and edit) two different parts of the same file easily.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From G@21:1/5 to Lawrence D'Oliveiro on Wed Mar 6 09:33:41 2024
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 4 Mar 2024 09:10:21 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 3 Mar 2024 09:10:32 GMT, G wrote:

    If you havo more then a few lines to copy or just check the
    differences between two similar files "vimdiff file1 file2" is quite
    useful. It has specific commands to copy from or to the other file.

    In normal editors, you use the same commands for cut/copy/paste as you
    would when editing a single file.

    And in vimdiff you can use those command if you want (it is still vim
    after all), or use the specific command if you want do things faster.

    In Emacs, you can have two files open side by side. Or even more than two.

    That's what "vimdiff" does: it automatically shows the two files side to side, highlights the differences, folds the part that are similar if they are long, and other stuff specific to the job of dealing with the differences between
    two files. All of this can be done in normal vim, of course, it's just a fast way of setting up for this very specific task.

    G

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Wed Mar 6 21:05:16 2024
    On 6 Mar 2024 09:33:41 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 4 Mar 2024 09:10:21 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 3 Mar 2024 09:10:32 GMT, G wrote:

    If you havo more then a few lines to copy or just check the
    differences between two similar files "vimdiff file1 file2" is quite >>>>> useful. It has specific commands to copy from or to the other file.

    In normal editors, you use the same commands for cut/copy/paste as
    you would when editing a single file.

    And in vimdiff you can use those command if you want (it is still vim
    after all), or use the specific command if you want do things faster.

    In Emacs, you can have two files open side by side. Or even more than
    two.

    That's what "vimdiff" does ...

    We already gathered that. We don’t need to start Emacs in a special mode
    to get that.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From G@21:1/5 to Lawrence D'Oliveiro on Thu Mar 7 09:50:04 2024
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 6 Mar 2024 09:33:41 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 4 Mar 2024 09:10:21 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 3 Mar 2024 09:10:32 GMT, G wrote:

    If you havo more then a few lines to copy or just check the
    differences between two similar files "vimdiff file1 file2" is quite >>>>>> useful. It has specific commands to copy from or to the other file. >>>>>
    In normal editors, you use the same commands for cut/copy/paste as
    you would when editing a single file.

    And in vimdiff you can use those command if you want (it is still vim
    after all), or use the specific command if you want do things faster.

    In Emacs, you can have two files open side by side. Or even more than
    two.

    That's what "vimdiff" does ...

    We already gathered that. We don’t need to start Emacs in a special mode
    to get that.

    We don't "need" to start vim in a special mode to get that either, but it's faster ad easier. As I said it's just the usual vim with the options you need to do what you want already there. If you prefer to do it the Emacs way you
    can start vim with one file, load the second and give the commands to start
    the "diff" mode; I just don't see why you would want to do that.

    G

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to All on Thu Mar 7 14:38:22 2024
    On 07.03.2024 10:50, G wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 6 Mar 2024 09:33:41 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 4 Mar 2024 09:10:21 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 3 Mar 2024 09:10:32 GMT, G wrote:

    If you havo more then a few lines to copy or just check the
    differences between two similar files "vimdiff file1 file2" is quite >>>>>>> useful. It has specific commands to copy from or to the other file. >>>>>>
    In normal editors, you use the same commands for cut/copy/paste as >>>>>> you would when editing a single file.

    And in vimdiff you can use those command if you want (it is still vim >>>>> after all), or use the specific command if you want do things faster. >>>>
    In Emacs, you can have two files open side by side. Or even more than
    two.

    That's what "vimdiff" does ...

    Actually, if all I want is edit two files with Vim I wouldn't
    use vimdiff but the ordinary vim call, because vimdiff does a
    lot that I usually just don't want (unless comparing files);
    e.g. the coloring of file differences.


    We already gathered that. We don’t need to start Emacs in a special mode >> to get that.

    We don't "need" to start vim in a special mode to get that either, but it's faster ad easier. As I said it's just the usual vim with the options you need to do what you want already there. If you prefer to do it the Emacs way you can start vim with one file, load the second and give the commands to start the "diff" mode; I just don't see why you would want to do that.

    Yes, you can load a second (or third, etc) file in one step by
    :split file2 or by :vsplit file3 (the latter for side by side).
    No extra command necessary. If we have provided the files on
    the command line already we need only :split (or :vsplit) to
    get two views of the first file and :n to see the second file
    in one of the split window.

    But note that the other poster is likely more interested in
    an argument or a flame war given that he wrote in a parallel
    thread: "Emacs is the world’s most powerful editor.", so he
    might not be interested in Vim facts or to learn about what
    Vim actually provides beyond his prejudice or preferences.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From G@21:1/5 to Janis Papanagnou on Thu Mar 7 18:50:47 2024
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    On 07.03.2024 10:50, G wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 6 Mar 2024 09:33:41 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 4 Mar 2024 09:10:21 GMT, G wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On 3 Mar 2024 09:10:32 GMT, G wrote:

    If you havo more then a few lines to copy or just check the
    differences between two similar files "vimdiff file1 file2" is quite >>>>>>>> useful. It has specific commands to copy from or to the other file. >>>>>>>
    In normal editors, you use the same commands for cut/copy/paste as >>>>>>> you would when editing a single file.

    And in vimdiff you can use those command if you want (it is still vim >>>>>> after all), or use the specific command if you want do things faster. >>>>>
    In Emacs, you can have two files open side by side. Or even more than >>>>> two.

    That's what "vimdiff" does ...

    Actually, if all I want is edit two files with Vim I wouldn't
    use vimdiff but the ordinary vim call, because vimdiff does a
    lot that I usually just don't want (unless comparing files);
    e.g. the coloring of file differences.

    Yes, if I just want to edit multiple files. But for the work I do (mostly integrating differential equations or similar stuff) I often have very similar programs and vimdiff is very useful to check and transfer differences.
    But you are right about the coloring so I have by default the usual code coloring disabled and keep the one about differences as when I am using
    vimdiff that's what I am interested in.

    We already gathered that. We don’t need to start Emacs in a special mode >>> to get that.

    We don't "need" to start vim in a special mode to get that either, but it's >> faster ad easier. As I said it's just the usual vim with the options you need
    to do what you want already there. If you prefer to do it the Emacs way you >> can start vim with one file, load the second and give the commands to start >> the "diff" mode; I just don't see why you would want to do that.

    Yes, you can load a second (or third, etc) file in one step by
    :split file2 or by :vsplit file3 (the latter for side by side).
    No extra command necessary. If we have provided the files on
    the command line already we need only :split (or :vsplit) to
    get two views of the first file and :n to see the second file
    in one of the split window.

    But note that the other poster is likely more interested in
    an argument or a flame war given that he wrote in a parallel
    thread: "Emacs is the world’s most powerful editor.", so he
    might not be interested in Vim facts or to learn about what
    Vim actually provides beyond his prejudice or preferences.

    Yep, but it was fun not feeding the troll...

    G

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Thu Mar 7 20:18:44 2024
    On 7 Mar 2024 09:50:04 GMT, G wrote:

    We don't "need" to start vim in a special mode to get that either, but
    it's faster ad easier.

    With Emacs, we have server mode and the “emacsclient” command to add more open files to the running instance. This can be done via a custom right-
    click option in a file manager, for example.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)