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

Re: function to save pairs of byte positions

Expand Messages
  • Tim Chase
    ... While I m not sure what you re attempting to accomplish in the ... Alternatively, you might try something like this ugly beast of a ...
    Message 1 of 2 , Sep 7, 2009
      > I'm working on a function to output the byte position of
      > characters in a text file. Just ASCII right now.
      > I already have a rough script which will open a new file and
      > place the byte position in there. However, I what I would like
      > to do it usual visual-mode to highlight the sequence of
      > characters and have the function output the beginning byte
      > position and ending byte position to a separate buffer.
      > so I was looking for an inbuilt function that - when in visual
      > mode - would output the beginning and end position. That data
      > doesn't seem to be exposed as a function though. SO I got to
      > think well I can move the cursor to the start position, output
      > its byte pos and then move to the end of the selection and
      > output its byte position, which starts to get a bit messy.

      While I'm not sure what you're attempting to accomplish in the
      big picture, you may be interested in any of the following:

      :help line() " which can be used like line("'<") or line('v')
      :help col()
      :help virtcol()
      :help `<
      :help getpos()

      Alternatively, you might try something like this ugly beast of a

      :vnoremap Q <esc>:redir =>command<cr>`<lt>g<c-g>`>g<c-g>:redir
      END<cr>:new<cr>:0put =substitute(command, 'Col[^\x00]*Byte
      \(\d\+\) of \d*', '\1', 'g')<cr>

      You don't have to ":new" and "0put =..." to put the content in a
      new window as you have the two values in the "command" variable
      in case you want to do something else with it.


      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.