TransWikia.com

Jumping to a byte offset, and displaying position as byte offset

Vi and Vim Asked by 200_success on December 27, 2020

How can I move the cursor to the nth byte in the buffer?

How can I display the current cursor position in the ruler in terms of the byte offset, rather than lines and columns? (Follow-up question: can it be displayed in both decimal and hexadecimal?)

2 Answers

:goto 2356

jumps to the 2356th byte in the buffer.

Use the %o field in 'statusline' or 'rulerformat' to display the byte number of the character under your cursor.

Use %O to display the value in hexadecimal format.

Reference:

:help :goto
:help 'statusline'
:help 'rulerformat'

Correct answer by romainl on December 27, 2020

To display the byte position you can use the following command

:echo line2byte(line("."))+col(".")-1

See Question: Get offset of current buffer in vim

Answered by Vivian De Smedt on December 27, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP