[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"
    }
}
相关推荐
梦游钓鱼6 小时前
vscode通过设置ctrl+鼠标滚轮设置终端字体大小
ide·vscode·编辑器
暮色驶过苍茫6 小时前
VSCode 自动更新问题解决记录
ide·vscode·编辑器
春蕾夏荷_7282977258 小时前
vscode 创建第一个python程序
vscode·python
星空9 小时前
vscode开发环境配置
ide·vscode·编辑器
70asunflower1 天前
VS Code 从 0 到 1 完全教程
vscode
蜗牛 Day Day Up1 天前
vscode运行TypeScript
ide·vscode·typescript
cmpxr_1 天前
【VSCode】在类似Trae的软件上使用VSCode的插件市场
ide·vscode·编辑器
时空无限2 天前
mac 如何用命令行操作 vscode 打开哪个文件夹
ide·vscode·macos
MarsBighead2 天前
VSCode Python 调试故障排查:`justMyCode` 配置项引发的血案
ide·vscode·python
R_.L2 天前
【云服务器】VSCode连接云服务器
服务器·vscode