[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"
    }
}
相关推荐
肖邦德夜曲10 分钟前
SSH连接:mobaXterm(windows)与VSCODE
ide·vscode·ssh
输出的都是我的36 分钟前
搭配GitHub Copilot 提升VS code使用技巧 - 新手向
vscode·python
TonyLee0171 天前
Vscode+Cline插件使用(AI编程)
vscode·ai编程
全干工程师—1 天前
在liunx下使用VScode检测到 #include 错误。请更新 includePath问题的解决方法
ide·vscode·编辑器
G018_star sky♬1 天前
在vscode的终端上运行vue -V,会出现 : 无法加载文件 C:\Users\31772\AppData\Roaming\npm\vue.ps1,因为在此系统上禁止运行脚本。
vue.js·vscode·npm
不染尘.1 天前
vscode远程连接centos
linux·vscode·centos·ssh
遇雪长安1 天前
Cortex-Debug使用PyOCD超时问题
vscode·gd32·pyocd·daplink·cortex-debug
学嵌入式的六子2 天前
如何使用VScode开发STM32【喂饭级教程】-全过程讲解
c语言·ide·vscode·stm32·单片机·嵌入式硬件
liujing102329292 天前
STM32_一文看懂!VSCode导入STM32项目及AI辅助开发
ide·vscode·编辑器