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

Stuck & confused

Expand Messages
  • M.C
    Hi I am new to macs (and kinda vim & mysql) and am having some problems with the above. I have installed both and can run the mysql server from terminal using
    Message 1 of 3 , Mar 13, 2007
    • 0 Attachment
      Hi

      I am new to macs (and kinda vim & mysql) and am having some problems with
      the above.

      I have installed both and can run the mysql server from terminal using
      'mysql -p'. I have used sql commands before and have a pretty good grasp on
      how to text edit in vim. I can also launch a vim window from terminal.

      The problem is I want to be able to launch vim and then use this window to
      launch mysql before submitting queries to the mysql server which are written
      in vim(the server is local on my comp btw). how would I put 'mysql -p' into
      vim so that I can connect to the server and then how would I submit the
      queries?

      I have looked for tutorials through google but all I keep getting are
      instructions how to text edit in vim.

      It is possible that I have go myself very muddled re how vim & mysql
      interact but any help you could give would be gratefully recieved....

      cheers
      --
      View this message in context: http://www.nabble.com/Stuck---confused-tf3396750.html#a9457175
      Sent from the Vim - Mac mailing list archive at Nabble.com.
    • Brian McKee
      ... Hash: SHA1 ... IIUC, you want to run a shell command and capture the output in vim. To run a command inside vim you preface it with :! ... enter to go
      Message 2 of 3 , Mar 13, 2007
      • 0 Attachment
        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        On 13-Mar-07, at 11:42 AM, M.C wrote:
        > The problem is I want to be able to launch vim and then use this
        > window to
        > launch mysql before submitting queries to the mysql server which
        > are written
        > in vim(the server is local on my comp btw). how would I put 'mysql -
        > p' into
        > vim so that I can connect to the server and then how would I submit
        > the
        > queries?

        IIUC, you want to run a shell command and 'capture the output' in vim.

        To run a command inside vim you preface it with :!
        :!ls will list your current directory, then prompt you to hit
        enter to go back to using vim

        To read in external files you use :r
        :r addMe.txt will add the file to your current document

        To run a command inside vim and read in the output you combine the
        commands (very vimmish)
        :r!ls will add the directory listing to the bottom of your document

        So, you should be able to do something like
        :r!mysql -e help
        or whatever - the sql I leave to you.

        HTH
        Brian
        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.6 (Darwin)
        Comment: Verify this email or encrypt your email for free - see gnupg.org

        iD8DBQFF9snMGnOmb9xIQHQRAstWAJ9MKA/ieYfOObBVIY0xbkcRj78JPQCeLdZt
        0MTOwGrib/WatFSX9BnYw4c=
        =cFXu
        -----END PGP SIGNATURE-----
      • Benji Fisher
        ... I do not think there is anything mac-specific about this question, so you may get more help on the general vim users list. If your SQL commands are in the
        Message 3 of 3 , Mar 14, 2007
        • 0 Attachment
          On Tue, Mar 13, 2007 at 11:56:59AM -0400, Brian McKee wrote:
          > -----BEGIN PGP SIGNED MESSAGE-----
          > Hash: SHA1
          >
          > On 13-Mar-07, at 11:42 AM, M.C wrote:
          > >The problem is I want to be able to launch vim and then use this
          > >window to
          > >launch mysql before submitting queries to the mysql server which
          > >are written
          > >in vim(the server is local on my comp btw). how would I put 'mysql -
          > >p' into
          > >vim so that I can connect to the server and then how would I submit
          > >the
          > >queries?
          >
          > IIUC, you want to run a shell command and 'capture the output' in vim.
          >
          > To run a command inside vim you preface it with :!
          > :!ls will list your current directory, then prompt you to hit
          > enter to go back to using vim
          >
          > To read in external files you use :r
          > :r addMe.txt will add the file to your current document
          >
          > To run a command inside vim and read in the output you combine the
          > commands (very vimmish)
          > :r!ls will add the directory listing to the bottom of your document
          >
          > So, you should be able to do something like
          > :r!mysql -e help
          > or whatever - the sql I leave to you.
          >
          > HTH
          > Brian

          I do not think there is anything mac-specific about this question,
          so you may get more help on the general vim users' list.

          If your SQL commands are in the vim buffer, you can yank them and
          paste to the command line. For example (starting in Normal mode)

          y$:<C-R>"

          will yank the current line, enter Command-line mode, and paste the
          yanked text. If you want to do this a lot, you may want to define a
          mapping for it.

          :help y
          :help c_CTRL-R

          If you want an interactive SQL session in vim, then some plugins
          may help. I have never used them myself. For example,
          http://www.vim.org/scripts/script.php?script_id=165
          (The site is behaving oddly. Maybe it is just me, but reloading a page
          seems to help when it initially comes up blank.)

          HTH --Benji Fisher
        Your message has been successfully submitted and would be delivered to recipients shortly.