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

Saving current word (Win32)

Expand Messages
  • Schuttberg@aol.com
    Hello, I want to save the current word into my personal dictionary. ... I want to close the dos box after doing the work. I know there is the :start command,
    Message 1 of 3 , Jun 29, 2002
    • 0 Attachment
      Hello,

      I want to save the current word into my personal dictionary.

      The following works fine:
      :execute "!echo " expand("<cword>") . " >> woertbuch.txt"

      I want to close the dos box after doing the work. I know there is the :start
      command, but
      :execute "!start echo " expand("<cword>") . " >> woertbuch.txt"
      just gives me "command not found".

      How do I place the start command? (or any other Idea?)


      Thank You

      Achim
    • Michael Naumann
      ... You got it almost right, but missed an important point. Try the following ... Also note, that there is a vim-only solution to your problem ... I would
      Message 2 of 3 , Jun 30, 2002
      • 0 Attachment
        29.06.2002 17:59:40, Schuttberg@... wrote:

        >Hello,
        >
        >I want to save the current word into my personal dictionary.
        >
        >The following works fine:
        > :execute "!echo " expand("<cword>") . " >> woertbuch.txt"

        You got it almost right, but missed an important point.
        Try the following
        :execute "!echo ".expand("<cword>") . " >> woertbuch.txt"


        >
        >I want to close the dos box after doing the work. I know there is the :start
        >command, but
        > :execute "!start echo " expand("<cword>") . " >> woertbuch.txt"
        >just gives me "command not found".
        >
        >How do I place the start command? (or any other Idea?)

        Also note, that there is a vim-only solution to your problem
        using redir, as in:
        :redir >>woertbuch.txt|exe "echo '".expand("<cword>")."'"|redir END

        I would probably even use quite another technique, provided that
        woertbuch.txt is not too large.
        I would set up a function/mapping that opens woertbuch.txt in a split vim-buffer,
        positions the cursor at the end and pastes the word there. This way I would always
        see what i'm filling in. This is esp. worth, since <cword> honors iskeyword, which
        may occasionally give undesired results.


        HTH, Michael
      • Benji Fisher
        ... I think the original version is equivalent. Remember that :execute accepts multiple arguments (like :echo) and inserts spaces in between ... How do I
        Message 3 of 3 , Jun 30, 2002
        • 0 Attachment
          On Sunday, June 30, 2002, at 10:17 AM, Michael Naumann wrote:

          > 29.06.2002 17:59:40, Schuttberg@... wrote:
          >
          >> Hello,
          >>
          >> I want to save the current word into my personal dictionary.
          >>
          >> The following works fine:
          >> :execute "!echo " expand("<cword>") . " >> woertbuch.txt"
          >
          > You got it almost right, but missed an important point.
          > Try the following
          > :execute "!echo ".expand("<cword>") . " >> woertbuch.txt"

          I think the original version is equivalent. Remember that :execute
          accepts multiple arguments (like :echo) and inserts spaces in between
          them. It could even be done thus:

          :execute "!echo" expand("<cword>") ">> woertbuch.txt"

          >> I want to close the dos box after doing the work. I know there is the
          >> :start
          >> command, but
          >> :execute "!start echo " expand("<cword>") . " >> woertbuch.txt"
          >> just gives me "command not found".

          I am not sure, but I would try debugging with something simpler:

          :!start echo 'hello world' >> woertbuch.txt
          :execute "!start echo 'hello world' >> woertbuch.txt"

          How do I place the start command? (or any other Idea?)
          >
          > Also note, that there is a vim-only solution to your problem
          > using redir, as in:
          > :redir >>woertbuch.txt|exe "echo '".expand("<cword>")."'"|redir END

          Other than doing it all in one line, is there a reason for :execute
          here? Untested:

          :redir >>woertbuch.txt
          :echo expand("<cword>")
          :redir END

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