vscode_neovim(vim enhanced)配置与使用@通过变量$MYVIMRC来修改vim配置文件_vscode neovim-程序员宅基地

技术标签: vscode  vim  ide  

neovim安装

refs@document

用scoop 安装

  • 如果您的网络环境允许,scoop安装时不错的选择

  • 通过nvim可以在终端(powershell)中启动neovim

  • (注意不是用neovim启动,而是nvim)

    •     NVIM v0.5.1
      ~
      ~                                     Nvim is open source and freely distributable
      ~                                               https://neovim.io/#chat
      ~
      ~                                    type  :help nvim<Enter>       if you are new!
      ~                                    type  :checkhealth<Enter>     to optimize Nvim
      ~                                    type  :q<Enter>               to exit
      ~                                    type  :help<Enter>            for help
      ~
      ~                                               Sponsor Vim development!
      ~                                    type  :help sponsor<Enter>    for information
      ~
      

scoop查询neovim安装目录

  • PS C:\Users\cxxu> scoop which nvim
    D:\exes\neovim\bin\nvim.exe
    
  • 这里的~表示用户家目录(%userProfile%)

安装vscode extension

插件配置

  • by command palette

    • 在这里插入图片描述
    • 搜索neovim path
  • 配置时注意区分linux path/windows path

使得配置生效

  • 重启窗口

    • ctrl+shift+p:

    • reload window

    • 在这里插入图片描述

vimrc 配置文件

  • vimrc 在neovim中的相对应的配置文件是init.vim(或者是init.lua)

    • :help init.vim

      • config init.vim init.lua vimrc exrc
              A file that contains initialization commands is generically called
              a "vimrc" or config file.  It can be a Vimscript or Lua file named
              "init.vim" or "init.lua" respectively.  It is an error to use both at
              the same time.  Each line in a "init.vim" is executed as an Ex command
              line.  See also vimrc-intro and base-directories.
          
              The config file is located at:
                      Unix            ~/.config/nvim/init.vim (or init.lua)
                      Windows         ~/AppData/Local/nvim/init.vim (or init.lua)
              or if $XDG_CONFIG_HOME is defined:
                                      $XDG_CONFIG_HOME/nvim/init.vim (or init.lua)
        
  • 然而,某些情况下您找不到这个文件,可以手动创建

  • 根据help 提示,在

    • %localAppData%\下创建相应的目录nvim
    • 并创建文件init.vim
    • 这样就可以完成配置
  • windows下重开一个nvim,可以看到效果

配置文件和$MYVIMRC

neovim配置

:help vim.init

 A file that contains initialization commands is generically called
        a "vimrc" or config file.  It can be a Vimscript or Lua file named
        "init.vim" or "init.lua" respectively.  It is an error to use both at
        the same time.  Each line in a "init.vim" is executed as an Ex command
        line.  See also vimrc-intro and base-directories.

        The config file is located at:
                Unix            ~/.config/nvim/init.vim (or init.lua)
                Windows         ~/AppData/Local/nvim/init.vim (or init.lua)

创建init.vim

  • for windows
    • powershell下可以执行:
      • new-item -Type File ~/AppData/Local/nvim/init.vim -Force
  • for linux
    • touch ~/.config/nvim/init.vim
编辑已创建的配置文件
  • edit $myvimrc(windows下部分大小写)
  • tab可以补全
    在这里插入图片描述

vim配置

  • . Execute Ex commands, from environment variables and/or files
            An environment variable is read as one Ex command line, where multiple
            commands must be separated with '|' or "<NL>".
                                                                    vimrc exrc
            A file that contains initialization commands is called a "vimrc" file.
            Each line in a vimrc file is executed as an Ex command line.  It is
            sometimes also referred to as "exrc" file.  They are the same type of
            file, but "exrc" is what Vi always used, "vimrc" is a Vim specific
            name.  Also see vimrc-intro.
    
            Places for your personal initializations:
                    Unix            $HOME/.vimrc or $HOME/.vim/vimrc
                    MS-Windows      $HOME/_vimrc, $HOME/vimfiles/vimrc
                                    or $VIM/_vimrc
                    Amiga           s:.vimrc, home:.vimrc, home:vimfiles:vimrc
                                    or $VIM/.vimrc
                    Haiku           $HOME/config/settings/vim/vimrc
    
            The files are searched in the order specified above and only the first
            one that is found is read.
    

:version( for vim)

Compiled by team+vim@tracker.debian.org
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     -perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          -ruby              +wildignore
+cursorbind        -lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        +mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
-farsi             -mouse_sysmouse    -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -ffile-prefix-map=/build/vim-8W0Acv/vim-8.2.3995=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro
-Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lsodium -lacl -lattr -lgpm -L/usr/lib/python3.10/config-3.10-x86_64-linux-gnu -lpython3.10 -lcrypt -ldl -lm -lm
配置文件信息
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
编辑配置文件
  • 进入到vim普通模式
  • 如果要编辑系统范围内的默认vim配置
  • :edit $VIM/vimrc
  • 其余配置文件类似操作

配置文件作用域

全局配置文件(linux)
  • 为所有用户配置的默认值
  • usually by creating /etc/vimrc or /etc/vim/vimrc
    • vimrc是文件而不是目录!
  • Depends on your version of vim and linux/unix
    • centos use the former one,the ubuntu use the later one
例如:配置所有用户自动打开行号显示
  • 配置脚本:

    • cat /etc/vim/vimrc |tail
      sudo tee -a /etc/vim/vimrc <<eof
      set nu
      eof
      
      cat /etc/vim/vimrc |tail
      
      
用户个人配置文件(linux)
  • 检查是否存在个人用户配置文件ls ~ -al|grep .vim

  • ls ~ -al|grep .vim
    -rw------- 1 cxxu_u22 cxxu_u22   7213 Jan  1 13:55 .viminfo
    -rw-r--r-- 1 root     root          7 Jan  1 13:52 etcvimrc
    
  • 如果没有.vimrc文件,手动创建一个

  • 用户的个人配置将覆盖系统的默认配置.

ref docs

使用本地参考文档:

  • :h vimrc
例如 neovim下执行
 Load user config (execute Ex commands from files, environment,).
        An environment variable (e.g. $VIMINIT) is read as one Ex command
        line, where multiple commands must be separated with '|' or <NL>.
                                        config init.vim init.lua vimrc exrc
        A file that contains initialization commands is generically called
        a "vimrc" or config file.  It can be a Vimscript or Lua file named
        "init.vim" or "init.lua" respectively.  It is an error to use both at
        the same time.  Each line in a "init.vim" is executed as an Ex command
        line.  See also vimrc-intro and base-directories.

        The config file is located at:
                Unix            ~/.config/nvim/init.vim (or init.lua)
                Windows         ~/AppData/Local/nvim/init.vim (or init.lua)
        or if $XDG_CONFIG_HOME is defined:
                                $XDG_CONFIG_HOME/nvim/init.vim (or init.lua)
                                    If Nvim was started with "-u {file}" then {
    file} is used as the config
        and all initializations until 5. are skipped. $MYVIMRC is not set.
        "nvim -u NORC" can be used to skip these initializations without
        reading a file.  "nvim -u NONE" also skips plugins and syntax
        highlighting.  -u
  If Nvim was started with -es all initializations until 5. are
        skipped.
                                                system-vimrc sysinit.vim
     a. The system vimrc file is read for initializations.  If
        nvim/sysinit.vim file exists in one of $XDG_CONFIG_DIRS, it will be
        used.  Otherwise the system vimrc file is used. The path of this file
        is given by the :version command.  Usually it's "$VIM/sysinit.vim".

                                                VIMINIT EXINIT $MYVIMRC
     b. Locations searched for initializations, in order of preference:
        -  $VIMINIT environment variable (Ex command line).
        -  User config: $XDG_CONFIG_HOME/nvim/init.vim.
        -  Other config: {
    dir}/nvim/init.vim where {
    dir} is any directory
           in $XDG_CONFIG_DIRS.
        -  $EXINIT environment variable (Ex command line).
        $MYVIMRC is set to the first valid location unless it was already
        set or when using $VIMINIT.

     c. If the 'exrc' option is on (which is NOT the default), the current
        directory is searched for two files.  The first that exists is used,
        the others are ignored.
        -  The file ".nvimrc"
        -  The file ".exrc"

编辑$VIMRC效果

  • 创建完对应文件后,就有这样的效果

  • 在这里插入图片描述

在线文档(推荐)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/xuchaoxin1375/article/details/121113414

智能推荐

高并发C/S的TCP版本golang实现_golang tcp高并发-程序员宅基地

文章浏览阅读682次。前面一篇文章写到的实现服务器只能连接一个客户端,没有发挥出go语言的协程特性,所以又可用如下方法实现高并发,多个客户端连接来完成:package mainimport ( "fmt" "net" "strings")func main() { // 创建监听套接字 listener, err := net.Listen("tcp", "127.0.0.1:8001") if err != nil { fmt.Println("listen err", err) return_golang tcp高并发

jvm调优:jmap -histo的使用_jmap histo-程序员宅基地

文章浏览阅读7.6k次。_jmap histo

java生成二维码 微信、支付宝、钉钉等等通用_java生成支付二维码-程序员宅基地

文章浏览阅读3.3k次,点赞6次,收藏13次。需要2个jar包 com.google.zxing 下的core.jar 和 javase.jar&lt;dependency&gt; &lt;groupId&gt;com.google.zxing&lt;/groupId&gt; &lt;artifactId&gt;core&lt;/artifactId&gt; &lt;version&gt;3.3.1&lt;/version&gt;&_java生成支付二维码

spring-boot获取form-data数据及json数据_springboot获取formdata参数-程序员宅基地

文章浏览阅读2.8w次,点赞2次,收藏5次。1. form-data参数获取 @RequestMapping("/isChartConfig") public Message isChartConfig(String tableName, String title, Message message) { if (StringUtils.isBlank(tableName) &amp;&amp; StringUt..._springboot获取formdata参数

Ubuntu常用的命令,及其总结_ubuntu命令使用实验总结-程序员宅基地

文章浏览阅读120次。update是更新软件列表,upgrade是更新软件。一般在update 之后会再加一句upgrade用pip安装文件,比如pip install tensorflow,如果这个软件包太大的话,可以先去网页上下载,得到一个.whl压缩包文件,打开文件所在的目录,执行pip install **.whl,即可执行安装。..._ubuntu命令使用实验总结

NUMA_--map-by numa:pe=3-程序员宅基地

文章浏览阅读123次。NUMANUMA简介NUMA的局限性Linux的NUMANUMA简介multi-processor systemmulti-processor & lockingNon-uniform memory accessNUMA的局限性NUMA架构的CPU – 你真的用好了么?Linux的NUMALinux的NUMA技术What is NUMA..._--map-by numa:pe=3

随便推点

图像去噪数据集_dnd数据集-程序员宅基地

文章浏览阅读2.8w次,点赞29次,收藏189次。Introduction目前效果出色的深度去噪方法大都采用监督学习的方法,需要采集输入-输出图像对(noisy/noise-free images pairs)建立训练数据集。数据集的建立是关键的任务。数据集的质量将直接决定去噪结果的质量。如何获取尽量多场景的图像数据,如何获得高质量的参考图像(ground truth),是目前研究的热点。The State of ArtsMe..._dnd数据集

LZF 压缩算法_dcpulzf-程序员宅基地

文章浏览阅读2.8k次。LZF Compressor先记录下来,后门慢慢研究_dcpulzf

Atomikos中文说明文档_com.atomikos.icatch.service-程序员宅基地

文章浏览阅读1.7k次。Atomikos 翻译文档(英文文档来源:下载安装包中START_HERE.html) ----译者:周枫请尊重劳动成果,转载请标明,英语水平有限,如有不准确地方请在评论中指出,谢谢官网地址:http://www.atomikos.com/Main/WebHome使用版本:AtomikosTransactionsEssentials-..._com.atomikos.icatch.service

UE4 打包之后Mesh没有材质问题_ue4打包材质丢失-程序员宅基地

文章浏览阅读1.2w次,点赞11次,收藏38次。原创文章,转载请注明出处。打包之后Mesh没有材质问题前言解决方案1>先确认资源被Cook2>确认你的材质所处的路径是不是有中文3>确认你的资源是什么类型,再去对应材质的Usage是否匹配前言UE4在打包之后有时候会遇到Material丢失的问题,编辑器下运行是正常的,如果你也遇到了,那么可以在这里停留一下看看有没有你想要的答案。举一个例子:我想在我的场景的马路上中摆放一些汽车模型,于是我用了Brush画刷的功能来往Mesh上随机填充我这些汽车,其实就是常用的刷植被的功能(注意._ue4打包材质丢失

NEON 常用函数讲解_vget_lane_f32-程序员宅基地

文章浏览阅读7.6k次,点赞18次,收藏65次。可见,打包 (zip)、拆包(unzip)并不是想当然的可逆的运算。注意,由于寄存器是交错存储的,所以内存保持不变!如果移位是负数 ,则变成截断的右移。注意,此时在寄存器是交错读取的!_vget_lane_f32

[CF1601C]Optimal Insertion-程序员宅基地

文章浏览阅读335次。OneInDark全球第二,yyds!!!_optimal insertion