2016-04-22 17:50
浏览 85

Sublime Text自动完成功能,括号中是否有变量?

If I already have this written

$company_id = isset($_POST['cid']) ? $_POST['cid'] : null;

And I want to wrap a function call around $_POST['cid'], is there a way to put that inside the autocompleted function's parentheses?

Instead of me typing this:

$company_id = isset($_POST['cid']) ? Validate::isId()$_POST['cid'] : null;

and then having to erase the right parenthesis, is there a shortcut to wrap the param when sublime autocompletes the function for me?

$company_id = isset($_POST['cid']) ? Validate::isId($_POST['cid']) : null;

Using Mac Yosemite and SublimeText 3.

图片转代码服务由CSDN问答提供 功能建议


  $ company_id = isset  ($ _POST ['cid'])?  $ _POST ['cid']:null; 

我想围绕 $ _ POST ['cid'] 包装函数调用 ,有没有办法把它放在自动完成函数的括号内?


  $ company_id = isset(  $ _POST ['cid'])? 验证:: isId()$ _ POST ['cid']:null; 

然后必须删除右括号,是否有一个快捷方式来包装参数 当sublime为我自动填充函数时?

  $ company_id = isset($ _ POST ['cid'])?  Validate :: isId($ _ POST ['cid']):null; 

使用Mac Yosemite和SublimeText 3.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • drt41563
    drt41563 2016-04-22 20:57

    You can create a custom snippet that accepts a SELECTION argument:


    Save The Code Below @:



    testFunction(${1:$SELECTION}, ${2:PlaceHolder_2})

    The use of placeholders, for example: ${1:placeholder_text_goes_here} , allows you to assign descriptive pre-selected regions throughout your snippet that can be navigated with Tab & Shift + Tab

    Additionally, you can replace one of the placeholders with $SELECTION, for example: ${1:$SELECTION} , which will pass the currently selected text as an argument if you execute the snippet from the command palette or a key-binding.

    To insert the snippet:

    • select the text to be passed as the $SELECTION argument
    • use Ctrl + Shift + P to launch the command palette
    • type Snippet: followed by the value of the <description> key in your sublime-snippet file

    For more information on snippets, see:

    SublimeText / Unofficial Docs / Snippets

    点赞 评论