请问emacs的surround插件很强大好用的是哪个?

用了evil surround 有点弱。我vim里可以做到这样的。不知道emacs下类似的插件叫什么,大家有什么好的分享吗 git

还有括号补全的插件哪个最好用。搜到好几个。。支持回车的时候会缩进和生成新行

func main(){|} --- 回车

func main(){
       |
}

我用smartparens。 写lisp的时候用lispy

回车换行缩进可以用

(with-eval-after-load 'smartparens
  (dolist (brace '("(" "{" "["))
    (sp-pair brace nil
             :post-handlers '(("||\n[i]" "RET")
                              ("| " "SPC"))
             :unless '(sp-point-before-word-p sp-point-before-same-p))))

你截图那个操作我直接在region上展开yasnippet(虽然不怎么用)

1 个赞

gif里是给单词 段落等textobject 添加环绕。。代码片段做不到啊?展开的代码片段是预定义的啊

这个我看到了好多括号类的插件,并不知道怎么选择。。

一直用smartparens,感觉还行。

看了下yas好像不能写$1$0$2这种包裹的snippet。那可以考虑试一下embrace

好的 我试试,折腾一个多礼拜了。差不多了这配置,到处抄导出改2333

请问surround有什么用?

我写blog的时候比较有用。给部分单词加 ` 这种东西,开发的时候偶尔也用得到。

单纯这个smartparens就可以,选中之后直接按paren key就好了,不过可能和evil冲突。

thing-at-point函数差不多可以模拟vim中的text object

如果只是简单的加个` 用不着插件 四行代码就够了

那个head/tail不支持, tag和func不是可以选中后使用s<和s)吗?

有一位坛友也开发了同类插件:很好用的surrounding工具

可以写自己呀?就像录脚本一样。

demo

   (defun tag-word-or-region (text-begin text-end)
     "Surround current word or region with given text."
     (interactive "sStart tag: \nsEnd tag: ")
     (let (pos1 pos2 bds)
       (if (and transient-mark-mode mark-active)
           (progn
             (goto-char (region-end))
             (insert text-end)
             (goto-char (region-beginning))
             (insert text-begin))
         (progn
           (setq bds (bounds-of-thing-at-point 'symbol))
           (goto-char (cdr bds))
           (insert text-end)
           (goto-char (car bds))
           (insert text-begin)))))
1 个赞

录脚本不就是固定了吗

可以用read-char

楼主的文件树是什么插件?

defx 配置可以参考我的ThinkVim