问题
I need a text editor which tells me the position of the cursor (so I can determine ranges of text to then load into strings). Unfortunately the text editors ive tried (TextWrangler, Aquamacs, EditPad) only tell me the line number the cursor is on, and the character index on that line. I need the index from the beginning of the file to that point - ie the absolute index. Any recommendations for an editor (or a technique im missing in the editors ive already got) which can tell me this?
回答1:
If you select some text in TextWrangler you will find 3 numbers at the bottom right of the screen. The first says how many characters are selected, the second how many words and the last how many lines. If you select everything from the beginning of the file until the position you are interested in, the first number will give you what you want.
回答2:
Emacs and Vim tell you. If you have Aquamacs, it's probably just as case of setting it up to show in your modeline:
As you can see - my modeline shows that the caret is on line 3, column 8 -> the (3,8)
来源:https://stackoverflow.com/questions/17153333/text-editor-which-tells-the-index-of-the-cursor-position