Loading ...
Sorry, an error occurred while loading the content.

Re: OT: Vi in a browser...

Expand Messages
  • Tim Chase
    ... You re so close, it could bite you :) It looks like you re getting hung up on expecting the solution to need visual mode rather than just using Ex
    Message 1 of 18 , Jun 1, 2007
    • 0 Attachment
      > Speaking of which, is there any quicker way to visually select the
      > entire file, analogous to ^A in other systems? I have to essentially do
      >
      > 1GVG<ctl-del>
      >
      > to stick everything into the scratchpad/clipboard/whatever to dump it
      > back into the item from whence it originally came, and that's just a
      > pain. Well, not so much a pain as an annoying itch I can't quite reach.
      >
      > I was thinking something along the lines of
      >
      > %V
      >
      > but that obviously won't work. :)

      You're so close, it could bite you :) It looks like you're
      getting hung up on expecting the solution to need visual mode
      rather than just using Ex commands.

      I frequently use

      :%d

      or if I need it to go to the system clipboard,

      :%d*
      :%d+

      I use these (and their "y"anking counterparts, ":%y") so
      regularly that they're ingrained muscle-memory.

      Because the y/d Ex command takes any range, I also regularly use

      :.,$d

      to do just from my current line to the EOF, or

      :1,.d

      to pull from the first line through the current line.

      -tim
    • Tobia
      ... Rpelace y with d if you want to cut instead of copy. Replace + with * if you want to use middle-click to paste (on X11.) Tobia
      Message 2 of 18 , Jun 1, 2007
      • 0 Attachment
        Gene Kwiecinski wrote:
        > Speaking of which, is there any quicker way to visually select the
        > entire file, analogous to ^A in other systems?

        To copy the entire file to the system clipboard, you can do:

        :%y+

        Rpelace y with d if you want to cut instead of copy.
        Replace + with * if you want to use middle-click to paste (on X11.)


        Tobia
      • A.J.Mechelynck
        ... It may depend on what you want to do with the selection: see the commands :yank , :put , delete , all of which accept a range and a register: ... To cut
        Message 3 of 18 , Jun 1, 2007
        • 0 Attachment
          Gene Kwiecinski wrote:
          >> Personally, I don't agree with you. When editing short text
          >> items on web pages, I feel that the overhead of copying/pasting
          >> back and forth from vim is too much. I am currently using the
          >
          > Speaking of which, is there any quicker way to visually select the
          > entire file, analogous to ^A in other systems? I have to essentially do
          >
          > 1GVG<ctl-del>
          >
          > to stick everything into the scratchpad/clipboard/whatever to dump it
          > back into the item from whence it originally came, and that's just a
          > pain. Well, not so much a pain as an annoying itch I can't quite reach.
          >
          > I was thinking something along the lines of
          >
          > %V
          >
          > but that obviously won't work. :)
          >
          >

          It may depend on what you want to do with the selection: see the commands
          ":yank", ":put", "delete", all of which accept a range and a register:

          To copy the whole file to the clipboard:

          :%y+

          To cut (delete) the whole file to the clipboard (not very useful for the whole
          file, but it may be interesting for a different range):

          :%d+

          To paste the clipboard after the last line:

          :$put+

          To paste the clipboard before the first line:

          :0put+

          To paste the clipboard linewise after the current line:

          :put+

          Without the + at the end, all these act on the default ("unnamed") register.


          Best regards,
          Tony.
          --
          Bravely bold Sir Robin, rode forth from Camelot,
          He was not afraid to die, Oh Brave Sir Robin,
          He was not at all afraid to be killed in nasty ways
          Brave, brave, brave, brave Sir Robin.
          "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
        • fREW
          ... Awesome. Tim is our ex friend. Or something? -- -fREW
          Message 4 of 18 , Jun 1, 2007
          • 0 Attachment
            On 6/1/07, Tim Chase <vim@...> wrote:
            > > Speaking of which, is there any quicker way to visually select the
            > > entire file, analogous to ^A in other systems? I have to essentially do
            > >
            > > 1GVG<ctl-del>
            > >
            > > to stick everything into the scratchpad/clipboard/whatever to dump it
            > > back into the item from whence it originally came, and that's just a
            > > pain. Well, not so much a pain as an annoying itch I can't quite reach.
            > >
            > > I was thinking something along the lines of
            > >
            > > %V
            > >
            > > but that obviously won't work. :)
            >
            > You're so close, it could bite you :) It looks like you're
            > getting hung up on expecting the solution to need visual mode
            > rather than just using Ex commands.
            >
            > I frequently use
            >
            > :%d
            >
            > or if I need it to go to the system clipboard,
            >
            > :%d*
            > :%d+
            >
            > I use these (and their "y"anking counterparts, ":%y") so
            > regularly that they're ingrained muscle-memory.
            >
            > Because the y/d Ex command takes any range, I also regularly use
            >
            > :.,$d
            >
            > to do just from my current line to the EOF, or
            >
            > :1,.d
            >
            > to pull from the first line through the current line.
            >
            > -tim
            >
            >
            >
            >
            >

            Awesome. Tim is our ex friend. Or something?

            --
            -fREW
          • Yakov Lerner
            ... But you can t read/save disk files out of javascript, can you ? I thought javascript can t. Yakov
            Message 5 of 18 , Jun 1, 2007
            • 0 Attachment
              On 5/30/07, Tim Chase <vim@...> wrote:
              > Just stumbled across this link:
              >
              > http://gpl.internetconnection.net/vi/
              >
              > for a basic implementation of Vi, authored in JavaScript. Sick,
              > sick, sick. So just in case you're on a foreign computer that
              > doesn't have vi/vim installed, and you need a fix, you can get it
              > via the web. :)

              But you can't read/save disk files out of javascript, can you ?
              I thought javascript can't.

              Yakov
            • panshizhu@routon.com
              ... When this is just a pain, why not just map ^A to your 1GVG ? So this come back to the topic: If anyone approaching to emulate vim in a browser
              Message 6 of 18 , Jun 3, 2007
              • 0 Attachment
                "Gene Kwiecinski" <gkwiecinski@...> 写于 2007-06-02 00:01:21:
                > >Personally, I don't agree with you. When editing short text
                > >items on web pages, I feel that the overhead of copying/pasting
                > >back and forth from vim is too much. I am currently using the
                >
                > Speaking of which, is there any quicker way to visually select the
                > entire file, analogous to ^A in other systems? I have to essentially do
                >
                > 1GVG<ctl-del>
                >
                > to stick everything into the scratchpad/clipboard/whatever to dump it
                > back into the item from whence it originally came, and that's just a
                > pain. Well, not so much a pain as an annoying itch I can't quite reach.

                When this is just a pain, why not just map ^A to your 1GVG<ctl-del> ?

                So this come back to the topic:

                If anyone approaching to emulate vim in a browser without actually calling
                vim, will it reads your .vimrc and to know you had mapped ^A to
                1GVG<ctl-del> ? unlikely.

                Then I don't think it makes too much sense reinventing a vi-like inside
                javascript.

                ―― After all, javascript *is* slow and I cannot afford to pay the overhead
                in any serious application. In most web-sites, disabling javascript is just
                something like upgrade my CPU from P4 to Core 2 Duo.
                --
                Sincerely, Pan, Shi Zhu. ext: 2606
              • Edward L. Fox
                Hi Pan, ... Well, personally I think the thing you should do is getting familiar with Vi-like editing styles, not mapping Vim to adapter your existing editing
                Message 7 of 18 , Jun 3, 2007
                • 0 Attachment
                  Hi Pan,

                  On 6/4/07, panshizhu@... <panshizhu@...> wrote:
                  > [...]
                  > When this is just a pain, why not just map ^A to your 1GVG<ctl-del> ?
                  >
                  > So this come back to the topic:
                  >
                  > If anyone approaching to emulate vim in a browser without actually calling
                  > vim, will it reads your .vimrc and to know you had mapped ^A to
                  > 1GVG<ctl-del> ? unlikely.

                  Well, personally I think the thing you should do is getting familiar
                  with Vi-like editing styles, not mapping Vim to adapter your existing
                  editing styles.

                  For example, in the other editors, if you want to copy the whole
                  article into the clipboard, you should first select all, then copy the
                  selected text into the clipboard. In Vim, "select all" is a pain. So
                  you mapped it to an easier shortcut.

                  But... But do we really need to select all first before copying the
                  text into the clipboard? Of course not. You can use "yank + motion" to
                  do it, like this: gg"+yG, it only costs 6 keystrokes. You can also use
                  ex command to do it, like this: :%y+, it only costs 4 keystrokes.

                  Well, maybe you would say, in the other editor, <c-a><c-c> is only 2
                  keystrokes. Yes, but to me, combination keys with Ctrl is much more
                  difficult to press than combination keys with Shift only. So I prefer
                  :%y+ to <c-a><c-c>. By the way, that's the primary reason that I
                  dislike Emacs.

                  > Then I don't think it makes too much sense reinventing a vi-like inside
                  > javascript.
                  >
                  > —— After all, javascript *is* slow and I cannot afford to pay the overhead
                  > in any serious application. In most web-sites, disabling javascript is just
                  > something like upgrade my CPU from P4 to Core 2 Duo.

                  As an experienced AJAX developer (:-P), I would responsibly tell you,
                  update a few fields inside a web page with AJAX is much much faster
                  than entirely refresh the page, especially when this refreshing
                  happens frequently.

                  > --
                  > Sincerely, Pan, Shi Zhu. ext: 2606

                  Regards,

                  Edward L. Fox
                • panshizhu@routon.com
                  ... This is just an example, since the Gene Kwiecinski feels selete all a pain. You may say he should not use select-all , but it is very likely that the
                  Message 8 of 18 , Jun 3, 2007
                  • 0 Attachment
                    "Edward L. Fox" <edyfox@...> 写于 2007-06-04 10:38:30:
                    > Hi Pan,
                    > On 6/4/07, panshizhu@... <panshizhu@...> wrote:
                    > > [...]
                    > > When this is just a pain, why not just map ^A to your 1GVG<ctl-del> ?
                    > >
                    >
                    > Well, personally I think the thing you should do is getting familiar
                    > with Vi-like editing styles, not mapping Vim to adapter your existing
                    > editing styles.
                    This is just an example, since the "Gene Kwiecinski" feels selete all a
                    pain. You may say he should not use "select-all", but it is very likely
                    that the similar senaro occurs for other keystrokes. I had many other
                    examples for that.

                    > but to me, combination keys with Ctrl is much more
                    > difficult to press than combination keys with Shift only.
                    Your mind may vary, but I feel no difference between press Shift, Alt and
                    Ctrl. I feel better only when I don't have to press any "chord" keys like
                    "ctrl,alt,shift" at all.

                    So what I had do is:
                    nnoremap ; :

                    With this map, I will not have to press the "Shift+:" to enter
                    command-mode, just the ";", and this saves me "thousands of keystrokes" and
                    I can use vim at least 30% faster.

                    You may say: "you should not use semicolon for entering command-mode, you
                    should follow the vi-way to entering command-mode by shift-colon." But
                    frankly speaking I don't think there's any sensible reason not using
                    semicolon as the shortcut of entering command-mode. In this case,
                    following the vi rule has no advantage and use shift-colon is solely
                    inefficient.

                    Everyone may have a completely different set of preferences on using vim,
                    since vim is designed to be a fullly-cumstomizable editor, if the
                    user-preferences such as .vimrc and plugins and color-schemes are not
                    loaded, chances are that the re-invented vi-clone inside browser has few
                    supporters.

                    --
                    Sincerely, Pan, Shi Zhu. ext: 2606
                  • Gene Kwiecinski
                    Just getting to email now, so this is essentially a consolidated reply to all who answered... ... That s about the shortest I could come up with, :%d+ , to do
                    Message 9 of 18 , Jun 4, 2007
                    • 0 Attachment
                      Just getting to email now, so this is essentially a consolidated reply
                      to all who answered...


                      >>Speaking of which, is there any quicker way to visually select the
                      >>entire file, analogous to ^A in other systems?

                      >To copy the entire file to the system clipboard, you can do:
                      > :%y+
                      >Rpelace y with d if you want to cut instead of copy.
                      >Replace + with * if you want to use middle-click to paste (on X11.)

                      That's about the shortest I could come up with, ":%d+", to do what I
                      want, but still not quite what I was looking for. I was kindasorta
                      expecting a normal-mode solution, like 'gg*V' or something, to avoid
                      even toggling the shift key all that much (think "baud" vs "bps").

                      The only thing I really use it for is to c&p from LookOut's email to
                      'vim', then back again. So I ^A the entire reply, dump it into a new
                      'vim' window, edit it to insert a new quotelevel, etc., then want to
                      "^A" it to get it back into LO. But it's repetitive/frequent enough to
                      make me want to shorten the command further.

                      Ain't "hung up" on visual mode or anything (hi Tim!), it's just that
                      when I don't want headers at the top, I can start from the bottom ('G'),
                      make my way to the top in visual ('1G'), then down my way past the
                      headers to *not* grab them when putting it all back. Or v/v if I want
                      to skip the signature. Etc.

                      The 'vim' instance used to do the editing is going to disappear
                      immediately after, so I'm not concerned about cut vs copy, etc.
                      Everything goes into the "clipboard", then dumped back into LO's reply
                      window, so a plain ':%d' won't work.


                      In a similar vein, I was never much on "visual" vs *real* 'vi' commands,
                      but it does come in handy to delete subroutines, etc. Eg, for the
                      format

                      sub sub1(){
                      ...
                      }

                      sub sub2(){
                      ...
                      }

                      all you need to do it find the initial "sub", then "V$%jj" to grab the
                      whole thing, and delete it, copy it, cut it, etc. Go into visual,
                      end-of-line (for the leading '{'), '%' (for the matching '}'), down a
                      coupla lines to grab trailing whitespace, then bam!, it's gone. And
                      it's a visual confirmation to make sure you don't go nuts and delete
                      more than you intended.

                      Point being that for some operations, visual mode is a lot more
                      reassuring.
                    • Hari Krishna Dara
                      ... Have you looked at the below Vim tip? http://www.vim.org/tips/tip.php?tip_id=805 Read through the comments as well as the original tip has been improved
                      Message 10 of 18 , Jun 4, 2007
                      • 0 Attachment
                        On Mon, 4 Jun 2007 at 11:27am, Gene Kwiecinski wrote:

                        > Just getting to email now, so this is essentially a consolidated reply
                        > to all who answered...
                        >
                        >
                        >>> Speaking of which, is there any quicker way to visually select the
                        >>> entire file, analogous to ^A in other systems?
                        >
                        >> To copy the entire file to the system clipboard, you can do:
                        >> :%y+
                        >> Rpelace y with d if you want to cut instead of copy.
                        >> Replace + with * if you want to use middle-click to paste (on X11.)
                        >
                        > That's about the shortest I could come up with, ":%d+", to do what I
                        > want, but still not quite what I was looking for. I was kindasorta
                        > expecting a normal-mode solution, like 'gg*V' or something, to avoid
                        > even toggling the shift key all that much (think "baud" vs "bps").
                        >
                        > The only thing I really use it for is to c&p from LookOut's email to
                        > 'vim', then back again. So I ^A the entire reply, dump it into a new
                        > 'vim' window, edit it to insert a new quotelevel, etc., then want to
                        > "^A" it to get it back into LO. But it's repetitive/frequent enough to
                        > make me want to shorten the command further.
                        >
                        > Ain't "hung up" on visual mode or anything (hi Tim!), it's just that
                        > when I don't want headers at the top, I can start from the bottom ('G'),
                        > make my way to the top in visual ('1G'), then down my way past the
                        > headers to *not* grab them when putting it all back. Or v/v if I want
                        > to skip the signature. Etc.
                        >
                        > The 'vim' instance used to do the editing is going to disappear
                        > immediately after, so I'm not concerned about cut vs copy, etc.
                        > Everything goes into the "clipboard", then dumped back into LO's reply
                        > window, so a plain ':%d' won't work.
                        >
                        >
                        > In a similar vein, I was never much on "visual" vs *real* 'vi' commands,
                        > but it does come in handy to delete subroutines, etc. Eg, for the
                        > format
                        >
                        > sub sub1(){
                        > ...
                        > }
                        >
                        > sub sub2(){
                        > ...
                        > }
                        >
                        > all you need to do it find the initial "sub", then "V$%jj" to grab the
                        > whole thing, and delete it, copy it, cut it, etc. Go into visual,
                        > end-of-line (for the leading '{'), '%' (for the matching '}'), down a
                        > coupla lines to grab trailing whitespace, then bam!, it's gone. And
                        > it's a visual confirmation to make sure you don't go nuts and delete
                        > more than you intended.
                        >
                        > Point being that for some operations, visual mode is a lot more
                        > reassuring.

                        Have you looked at the below Vim tip?
                        http://www.vim.org/tips/tip.php?tip_id=805

                        Read through the comments as well as the original tip has been improved
                        over a few iterations in the comments.

                        --
                        Hari



                        ____________________________________________________________________________________Ready for the edge of your seat?
                        Check out tonight's top picks on Yahoo! TV.
                        http://tv.yahoo.com/
                      Your message has been successfully submitted and would be delivered to recipients shortly.