现在的位置: 首页 > 综合 > 正文

SciTE4AutoHotkey新建文件默认编码 UTF-8 with BOM

2014年03月29日 ⁄ 综合 ⁄ 共 997字 ⁄ 字号 评论关闭

若SciTE4AutoHotkey,能在新建时自动选编码 为 带BOM的UTF-8 的就省事 省心了。

可通过配置SciTEGlobal.properties、SciTEUser.properties无法解决这个难题,似乎是个bug。

通过菜单  工具 Scite4AutoHotkey settings...设置也只能使新建的文件编码为UTF-8 NO BOM

经过无数次的搜索 以及 研究SciTE的lua配置,终于找到解决问题的方法:

就是在Scite的lua自启动脚本中添加:

--sunwind(1576157)搜集整理
-- event OnClear 完美解决新建文件时默认的文件编码
local oldOnClear = OnClear
function OnClear()
  if oldOnClear ~= nil then 
     if oldOnClear() then 
         return true  
     end 
  end 
  if props['FileName'] == "" then 
--~       新建时默认采用UTF-8带BOM编码方式  
      scite.MenuCommand(IDM_ENCODING_UTF8) 
--~       新建时默认采用UTF-8无BOM编码方式  
--~       scite.MenuCommand(IDM_ENCODING_UCOOKIE) 
  end 
  return false;
end

针对SciTE4AutoHotkey来说,就是找到UserLuaScript.lua文件,加上上述代码重启SciTE4AutoHotkey就可以了。

可以通过右击工具条来编辑UserLuaScript.lua文件

UserLuaScript.lua文件位置

\SciTE\
|_______ SciTE.exe
|_______ SciTE.chm
|_______ \user\
         |______ UserLuaScript.lua...

 

 

附赠:自动完成() {} [ ]  " "  %% ' '等

local toClose = { ['('] = ')', ['{'] = '}', ['['] = ']', ['"'] = '"', ["'"] = "'" , ["%"] = "%" }  

function OnChar(charAdded)  
    if toClose[charAdded] ~= nil then  
        editor:InsertText(editor.CurrentPos,toClose[charAdded])  
    end  
end 

【上篇】
【下篇】

抱歉!评论已关闭.