> 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
one-liner:
: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.
-tim
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---