[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"
    }
}
相关推荐
小白也有IT梦17 小时前
VSCode代理配置导致的SSL证书验证错误及解决方案
vscode·copilot·代理
Eiceblue19 小时前
在.NET用C#将Word文档转换为HTML格式
开发语言·vscode·c#·html·word·.net
m0_7482356120 小时前
vscode配置django环境并创建django项目(全图文操作)
vscode·django·sqlite
前端小尘1 天前
多语言插件i18n Ally的使用
javascript·vscode·typescript·json
MDY12191 天前
后端程序打成 JAR 包的详细步骤及解释
java·开发语言·vscode·jar
Ctrl_Cver1 天前
vscode accelerate deepspeed配置
ide·vscode·编辑器
Giser板栗糖1 天前
vscode——如何让标点总是成对出现
ide·vscode·编辑器
Hi-Jimmy1 天前
【AI插件】在VS Code中免费使用GitHub Copilot
ide·vscode·ai·github copilot
IT利刃出鞘1 天前
VS Code--常用的插件
vscode
天航星2 天前
VSCode 使用默认profile打开文件
ide·vscode·编辑器