[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"
    }
}
相关推荐
zhanglianzhao11 小时前
Win 11 WSL 配置Claude code 并在VsCode中使用
ide·vscode·编辑器·claude·cladue code
Keying,,,,11 小时前
VScode中终端闪退问题
ide·vscode·编辑器
热爱生活的五柒11 小时前
如何在vscode中使用Claude code以及插件中配置setting.json无效的解决方法
ide·vscode·编辑器
浩瀚之水_csdn13 小时前
vscode中运行html语言
ide·vscode·html
JQLvopkk14 小时前
VSCode基础使用
ide·vscode·编辑器
春日见14 小时前
docker崩溃,闪退,与vscode断开连接
vscode·docker·容器
一个没有本领的人14 小时前
vscode选择了正确的解释器,但终端显示运行的依然为原来的python版本
ide·vscode·python
学嵌入式的小杨同学14 小时前
【嵌入式 GUI 实战】LVGL+MP3 播放器:从环境搭建到图形界面开发全指南
linux·c语言·开发语言·vscode·vim·音频·ux
学嵌入式的小杨同学1 天前
从零打造 Linux 终端 MP3 播放器!用 C 语言实现音乐自由
linux·c语言·开发语言·前端·vscode·ci/cd·vim
badfl1 天前
VSCode Claude Code插件配置教程:使用、配置中转API、常见问题
人工智能·vscode·ai