[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"
    }
}
相关推荐
JohnnyCS16 小时前
VSCode 自动换行设置完全指南
vscode·编辑器
小龙报17 小时前
【算法通关指南:算法基础篇】二分算法: 1.A-B 数对 2.烦恼的高考志愿
c语言·开发语言·数据结构·c++·vscode·算法·二分
lightqjx1 天前
VS Code 的安装与如何搭建C/C++开发环境?
vscode·c/c++开发工具·vs code安装教程·vs code的使用
bu_shuo1 天前
Windows电脑使用VSCode远程控制Windows主机方法记录
windows·vscode·ssh·powershell
zhensherlock1 天前
Protocol Launcher 系列:一键唤起 Windsurf 智能 IDE
javascript·ide·vscode·ai·typescript·github·ai编程
喵手1 天前
Python爬虫实战:VS Code 扩展市场热门榜单“脱壳”实战!
vscode·爬虫·python·爬虫实战·零基础python爬虫教学·vscode扩展市场热门榜单·vs热门榜单数据采集
zhensherlock1 天前
Protocol Launcher 系列:一键唤起 VSCodium 智能 IDE
javascript·ide·vscode·typescript·开源·编辑器·github
FreeFly辉1 天前
VScode搭建javaDemo
java·vscode
lanhuazui101 天前
vscode打不开终端窗口
ide·vscode·编辑器
蒙塔基的钢蛋儿1 天前
使用STM32CUEBEIDE/S32DS 开发时,生成compile_commands.json 方便VSCODE智能提示
vscode·stm32·单片机·json