2013-11-03 29 views
1

我寫一個乳膠文件,我想插入重音符號..避免引用自動完成時反斜線插入

假設我想插入重音符號的E:è

如果我想寫它使用:

\`e 

但隨着崇高自動完成,當我插入反引號,我得到

\`e` 

所以我必須刪除額外的反引號每次我插入重音字符..有沒有辦法避免結束報價,如果第一個報價前面是反斜槓?

感謝

回答

3

嘗試添加以下到您的用戶鍵綁定。

{ "keys": ["'"], "command": "insert_snippet", "args": {"contents": "'"}, "context": 
    [ 
     { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 
     { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 
     { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true }, 
     { "key": "preceding_text", "operator": "not_regex_contains", "operand": "['a-zA-Z0-9_]$", "match_all": true }, 
     { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.single", "match_all": true }, 
     { "key": "preceding_text", "operator": "regex_contains", "operand": "\\\\$", "match_all": true }, 
     { "key": "selector", "operator": "equal", "operand": "text.tex", "match_all": true } 
    ] 
} 

我把默認的鍵綁定中自動配對引號的現有鍵綁定。然後,我更改了片段,以便它只輸入單個字符。您可以將其更改爲insert命令,但它並不重要。然後我將最後2個條目添加到上下文中。第一個檢查前面的文字\。第二個限制鍵綁定到範圍爲text.tex.latex的文件。第二項沒有必要,但如果它不存在,它將適用於所有文件類型,而不僅僅是tex文件。

編輯

雙引號解決方案

{ "keys": ["\""], "command": "insert_snippet", "args": {"contents": "\""}, "context": 
    [ 
     { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 
     { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 
     { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true }, 
     { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"a-zA-Z0-9_]$", "match_all": true }, 
     { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double", "match_all": true }, 
     { "key": "preceding_text", "operator": "regex_contains", "operand": "\\\\$", "match_all": true }, 
     { "key": "selector", "operator": "equal", "operand": "text.tex", "match_all": true } 
    ] 
} 

要重申,我開始與雙引號的自動對關鍵裝訂(默認),並增加了兩個方面的條目。不解析意味着你有一些畸形的json。如果我不得不猜測,你必須有很多/沒有足夠的\逃脫。

EDIT2

同樣的程序。希望我這次得到正確的報價:)

{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`"}, "context": 
    [ 
     { "key": "selector", "operator": "equal", "operand": "text.tex.latex"}, 
     { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 
     { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 
     { "key": "preceding_text", "operator": "regex_contains", "operand": "\\\\$", "match_all": true } 
    ] 
} 
+0

它確實工作.. :)我不明白它爲什麼它與反引號報價,我試圖使它與正常報價工作.. – gc5

+0

爲了使它與正常的引用一起工作,用'''替換鍵和內容中的'''',這是可行的,因爲在這種情況下按'''鍵時,它正在運行一個命令。一個單引號默認的綁定是輸入配對引號 – skuroda

+0

它不工作..它解析失敗..你能否把它添加到你的答案嗎?我也試過'\「'但它不起作用.. – gc5