Is it possible to show the exact position in Sublime Text 2?

怎甘沉沦 提交于 2020-01-01 01:13:08

问题


I've been learning Markdown, and using the Python Markdown package, which often returns the following when I try to convert text that has been pasted in from the web:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in 
position 1611: ordinal not in range(128)

At the bottom of my editor I currently see this:

COMMAND MODE, Line X, Column Y

Is there a setting in Sublime Text 2 that will show the full position (as in 1611 in the example above) at all times so I can quickly find the bad character?


回答1:


You could make a simple python script to do this.

1. Save this code to your User folder as characterCounter.py (Preferences > Browse Packages > User):

import sublime, sublime_plugin

class PositionListener(sublime_plugin.EventListener):
  def on_selection_modified(self,view):
    text = "Position: "
    sels = view.sel()
    for s in sels:
        text += " " + str(s.begin())
        if not s.empty():
            text += "-" + str(s.end()) + " "
    view.set_status('exact_pos', text)

2. Then restart Sublime Text to have it loaded.



来源:https://stackoverflow.com/questions/12943594/is-it-possible-to-show-the-exact-position-in-sublime-text-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!