[vscode] 创建erlang gen_serve 文件快捷方式

点击左下角功能按钮,代码片段,新建全局代码片段,然后输入自定义内容就可以

复制代码
{
    "Erlang gen_server": {
        "prefix": "genserver",
        "body": [
            "-module(${1:module_name}).",
            "-behaviour(gen_server).",
            "",
            "%% API",
            "-export([start_link/0]).",
            "",
            "%% gen_server callbacks",
            "-export([init/1, handle_call/3, handle_cast/2, handle_info/2,",
            "         terminate/2, code_change/3]).",
            "",
            "-record(state, {}).",
            "",
            "%%%===================================================================",
            "%%% API",
            "%%%===================================================================",
            "",
            "start_link() ->",
            "    gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).",
            "",
            "%%%===================================================================",
            "%%% gen_server callbacks",
            "%%%===================================================================",
            "",
            "init([]) ->",
            "    {ok, #state{}}.",
            "",
            "handle_call(Request, _From, State) ->",
            "    lager:error(\"Unhandled call: ===> ~p\", [Request]),",
            "    Reply = ok,",
            "    {reply, Reply, State}.",
            "",
            "handle_cast(Msg, State) ->",
            "    lager:error(\"Unhandled cast: ===> ~p\", [Msg]),",
            "    {noreply, State}.",
            "",
            "handle_info(Info, State) ->",
            "    lager:error(\"Unhandled info: ===> ~p\", [Info]),",
            "    {noreply, State}.",
            "",
            "terminate(Reason, _State) ->",
            "    lager:error(\"Server terminated: ===> ~p\", [Reason]),",
            "    ok.",
            "",
            "code_change(_OldVsn, State, _Extra) ->",
            "    {ok, State}."
        ],
        "description": "Template for an Erlang gen_server"
    }
}
相关推荐
初遇你时动了情2 小时前
flutter vscode 终端无法使用fvm 版本切换、项目运行
ide·vscode·flutter
xxxxxue3 小时前
VS Code 隐藏顶部标题栏中间的文字
vscode·隐藏·标题栏
Aldrich_3210 小时前
蓝桥杯嵌入式赛道—-软件篇(GPIO输出模式配置)
c语言·vscode·stm32·单片机·嵌入式硬件·蓝桥杯
应茶茶1 天前
VsCode通过SSH远程连接云服务器遇到主机密钥变更问题
服务器·vscode·ssh
小龙报1 天前
《VScode搭建教程(附安装包)--- 开启你的编程之旅》
c语言·c++·ide·vscode·单片机·物联网·编辑器
buvsvdp50059ac2 天前
如何在VSCode中设置Python解释器?
ide·vscode·python
天天向上10242 天前
VueUse的使用
前端·vue.js·vscode
锻炼²2 天前
(已解决)vscode打开stm32cubemx生成的工程报红色波浪线警告
ide·vscode·stm32·stm32cubemx·vscode打开keil工程
言6663 天前
vscode 设置中文-语言
ide·vscode·编辑器
百***12223 天前
vscode配置django环境并创建django项目(全图文操作)
vscode·django·sqlite