[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"
    }
}
相关推荐
NiceAsiv13 小时前
VSCode之打开python终端 取消conda activate的powershell弹窗
vscode·python·conda
胖好白14 小时前
【RK3588开发】RK3588的Debian系统环境搭建
linux·vscode·debian
Hiweir ·17 小时前
ROS Noetic教程------VSCode创建ROS话题通讯--发布方的简单流程
vscode·python·ros noetic·ros noetic教程
肆悟先生18 小时前
2.1visual Studio code 插件
ide·vscode·编辑器·html5
LYOBOYI12319 小时前
使用vscode创建qt的qml项目
ide·vscode·编辑器
夜雨听萧瑟2 天前
VSCode的clangd插件简单介绍和使用
vscode
GDAL2 天前
vscode 使用正则查找替换
ide·vscode·正则表达式·编辑器
HERR_QQ2 天前
【cpp tool】GDB coredump vscode GUI 和多线程常用笔记
ide·笔记·vscode
研來如此2 天前
VSCode连接远程服务器
服务器·ide·vscode
GHL2842710902 天前
VSCode无法连接虚拟机,报错“XHR failed“,手动部署VSCode Server
ide·vscode·编辑器