是否有可能在Sublime Text 2中显示确切的位置?

时间:2022-05-10 23:47:53

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:

我一直在学习Markdown,并使用Python Markdown软件包,当我尝试转换从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?

Sublime Text 2中是否有一个设置可以随时显示完整位置(如上例中的1611),这样我可以快速找到坏字符?

1 个解决方案

#1


55  

You could make a simple python script to do this.

你可以制作一个简单的python脚本来做到这一点。

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

1.将此代码作为characterCounter.py(首选项>浏览包>用户)保存到用户文件夹:

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.

2.然后重新启动Sublime Text以加载它。

#1


55  

You could make a simple python script to do this.

你可以制作一个简单的python脚本来做到这一点。

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

1.将此代码作为characterCounter.py(首选项>浏览包>用户)保存到用户文件夹:

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.

2.然后重新启动Sublime Text以加载它。