问题
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