[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"
    }
}
相关推荐
行走的陀螺仪11 小时前
.vscode 文件夹配置详解
前端·ide·vscode·编辑器·开发实践
这儿有一堆花15 小时前
重磅推出!Google Antigravity:一次 “以 Agent 为中心 (agent-first)” 的 IDE 革命
vscode·ai·ai编程·googlecloud
j***518921 小时前
vscode配置django环境并创建django项目(全图文操作)
vscode·django·sqlite
skywalk81631 天前
FreeBSD系统安装VSCode Server(未成功,后来是在FreeBSD系统里的Linux虚拟子系统里安装启动了Code Server)
ide·vscode·编辑器·freebsd
深海潜水员1 天前
【MonoGame游戏开发】| 牧场物语实现 第一卷 : 农场基础实现 (下)
vscode·游戏·c#·.net·monogame
skywalk81631 天前
linux安装Code Server 以便Comate IDE和CodeBuddy等都可以远程连上来
linux·运维·服务器·vscode·comate
喂自己代言2 天前
VS Code中提升效率的实用快捷键(中英双语版)
vscode
爱吃泡芙的小白白2 天前
vscode、anaconda、git、python配置安装(自用)
ide·git·vscode·python·anaconda·学习记录
a***13143 天前
vscode配置django环境并创建django项目(全图文操作)
vscode·django·sqlite
YY&DS3 天前
VSCode Remote SSH 远程 Linux 无法连接
vscode