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

99977Re: Writing text to a file (invisibly)

Expand Messages
  • Tim Johnson
    Jan 3, 2009
    • 0 Attachment
      On Friday 02 January 2009, Tony Mechelynck wrote:

      > What do you call "invisibly"?
      Minimum output visible to the user .....
      Here's what I have tried:
      select text in visual mode
      y " yank to " register
      :let lines = @" " read register into variable
      :call writefile(lines,'targetfile')
      " this command fails since writefile() needs the first arg as list
      " so either another function is needed or a way to coerce `lines' to
      " a list

      > :help :function
      > :help :command
      >
      > to write your own functions and ex-commands
      To encapsulate this functionality into a function will have a number
      of applications for me. One application would be to emulate the emacs
      "scratch" buffer which allows the user to enter some elisp code, evaluate
      it and see the results read into the buffer
      this could be accomplished by 'targetfile' as source code as an argument
      to a call to a binary => exe ":r!language-binary targetfile"
      or given permission (and shebang) of course:
      exe ":r!targetfile"

      " simpler example follows:

      " I've alread written the following function:
      function! ComposeTime()
      exe "norm! 0v%y$"
      let arg = @"
      exe ":r !/home/http/run/baker/reb/compose-time.r " . arg
      exe "norm! kJ"
      endfunction
      output =>
      Line before:
      [[10:00 11:54][12:52 13:03][13:06 13:52][14:04 15:01]]
      line after:
      [[10:00 11:54][12:52 13:03][13:06 13:52][14:04 15:01]] 3:48
      :-) my hand-dandy timeclock!
      > None of the above requires python; but I recommend using at least a
      > Normal build of Vim (otherwise you won't have expression evaluation and
      > it makes script writing much harder -- no ifs, no whiles, no functions,
      > etc.
      I concur..
      Thanks to all for the input. I hope all finds this an interesting topic.
      All comments are contributing to my "vim education" :-)
      Sounds like coercing a string to a list would be the action that finishes
      this. I will look into that.
      Happy New Year!
      Tim

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Show all 6 messages in this topic