Comments on: Éviter que Sublime Text n’écrase les parenthèses fermantes http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/ Du code, du cul Fri, 06 Sep 2019 09:34:15 +0000 hourly 1 https://wordpress.org/?v=4.9.7 By: Sam http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/#comment-15381 Sun, 03 Nov 2013 06:19:34 +0000 http://sametmax.com/?p=7103#comment-15381 Pour ceux qui préfèrent la version de Groug, voici le code en entier (car sur SO il est tronqué):

    { "keys": ["\""], "command": "insert", "args": {"characters": "\""}, "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": "^\"", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "[^\"]$", "match_all": true }
        ]
    },
    { "keys": ["\""], "command": "move", "args": {"by": "characters", "forward": true}, "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": "^\"", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "\"$", "match_all": true }
        ]
    },

    { "keys": [")"], "command": "insert", "args": {"characters": ")"}, "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": "^\\)", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "[^(]$", "match_all": true }
        ]
    },
    { "keys": [")"], "command": "move", "args": {"by": "characters", "forward": true}, "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": "^\\)", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "\\($", "match_all": true }
        ]
    },


    { "keys": ["'"], "command": "insert", "args": {"characters": "'"}, "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": "^'", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "[^']$", "match_all": true }
        ]
    },
    { "keys": ["'"], "command": "move", "args": {"by": "characters", "forward": true}, "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": "^'", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "'$", "match_all": true }
        ]
    },


    { "keys": ["]"], "command": "insert", "args": {"characters": "]"}, "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": "^\\]", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "[^\\[]$", "match_all": true }
        ]
    },
    { "keys": ["]"], "command": "move", "args": {"by": "characters", "forward": true}, "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": "^\\]", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "\\[$", "match_all": true }
        ]
    },

    { "keys": ["}"], "command": "insert", "args": {"characters": "}"}, "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": "^\\}", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "[^\\{]$", "match_all": true }
        ]
    },
    { "keys": ["}"], "command": "move", "args": {"by": "characters", "forward": true}, "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": "^\\}", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "\\{$", "match_all": true }
        ]
    }

]]>
By: Sam http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/#comment-14456 Tue, 01 Oct 2013 13:34:10 +0000 http://sametmax.com/?p=7103#comment-14456 :-)

]]>
By: Duckie http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/#comment-13853 Sun, 01 Sep 2013 23:25:43 +0000 http://sametmax.com/?p=7103#comment-13853 vim c’est kiffant mais sur windows c’est crado, autant utiliser Sublime dans ce cas faute de taffer sous un Unix.

Les gars vous m’avez plié de rire avec le trombone à côté des commentaires.

]]>
By: groug http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/#comment-13364 Thu, 15 Aug 2013 17:16:47 +0000 http://sametmax.com/?p=7103#comment-13364 Sur SO, quelqu’un a posé la même question, et a une solution un chouia mieux que celle de Sam : même comportement, mais le caractère fermant reste remplacé si le caractère précédent est le caractère ouvrant :
Lien SO

]]>
By: groug http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/#comment-13363 Thu, 15 Aug 2013 16:58:57 +0000 http://sametmax.com/?p=7103#comment-13363 Mouais, après quelques heures d’utilisation, j’ai un nouveau problème.
Maintenant, quand je tape une balise ouvrante, que je tape du code puis tape la balise fermante, ça m’en rajoute une deuxième (normal, en fait), et je me retrouve à avoir un nouveau problème là où je n’en avais pas pour en corriger un autre.
Du coup, à moins de désactiver l’ajout automatique de balise fermante, c’est choisir entre la peste et le choléra.
La peste pour la création d’une ligne de code, le choléra pour la modification de cette ligne.

]]>
By: cendrieR http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/#comment-13357 Thu, 15 Aug 2013 12:12:55 +0000 http://sametmax.com/?p=7103#comment-13357 Merci !

]]>
By: jean roger http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/#comment-13355 Thu, 15 Aug 2013 11:33:49 +0000 http://sametmax.com/?p=7103#comment-13355 Sinon, pour les champions, ya vim.

]]>
By: Fred http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/#comment-13350 Thu, 15 Aug 2013 09:13:48 +0000 http://sametmax.com/?p=7103#comment-13350 Bon je ne connais pas ST. Perso j’utilise vi sous Unix et notepad++ sous zindow. Mais je me dépêche en ce moment même d’aller combler cette lacune.
Ceci dit, moi non plus je n’apprécie pas qu’un outil se permette de réfléchir à ma place. Surtout qu’il existe des cas particuliers où on met des parenthèses non pairées (par exemple dans le case…esac du shell).

Merci donc de ces infos que je lis avidement ;)

]]>
By: viki53 http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/#comment-13336 Wed, 14 Aug 2013 20:00:25 +0000 http://sametmax.com/?p=7103#comment-13336 Fuck yeah!

Je t’aime, Sam, mon sauveur !

Plus sérieusement, ST commençait à me les hacher menu à la longue…

]]>
By: groug http://sametmax.com/eviter-que-sublime-text-necrase-les-parentheses-fermantes/#comment-13335 Wed, 14 Aug 2013 19:51:21 +0000 http://sametmax.com/?p=7103#comment-13335 Je n’ai jamais pris le temps de chercher une solution, mais ça m’agace suffisamment pour venir poster un commentaire de remerciements !
Et heureusement que SublimeLinter est là pour raler, sinon, bien souvent, je m’en apercevrais qu’à l’exécution…

]]>