转)vimscript in 5 minus
Vim 01 Recorder

Vim 01 Recorder

Chose Your Dotfile to start the vim

1
vim -u {path to your .vimrc}

Recorder of Vim

This Chapter mainly introduces the Recorder in vim,Which is used to do some repeated operations.This function is also called a macro.

for more information try :help recording

This section will introduce related concept/function of recording function. Which help us to understand how this works, and what we should pay attention to it.

register of vim: register is a superset of macro, it contains more function. In this part we should know, register can store some string or operations to help subsequent use.

Status:
Using :registers or :reg to check those we have registered, or add the registers’s name behind to show those u’re interested in.

1
2
3
4
5
:reg a b c 
--- Registers ---
"a register a content
"b register b content
"c register c content

Lifecycle
The information in registers will not disappear with the window closed. But maybe with the system-level’s open-close. we should test this!!! So we can store some snippet,pwd,etc.


Vim 00 Basic Opeation

Vim 00 Basic Opeation

this is the Note record the vimtutor (the basic usage of vim.)
@Aiken 2021

delete command

Most of the command can use NUM to repeat it.
d num command means delete num times with args below:
c means del and change mode to insert:


Vim Configuration 03 Spacevim Setup

Vim Configuration 03 Spacevim Setup

@Aiken 2021 this file is use to record how to config out vim’ by spacevim.
I’ll write this doc with three Parts:

  • Install and envs, Plugins(including the LSP), KeyShort
  • Attention: we have much to do if we want to install some other plugins.
    maybe it not a good way to set the vim.

INSTALL SPACEVIM AND CONFIG IT

Install: SpaceVim via the offical websize:

1
2
The COMMAND is like:
curl -sLf https://spacevim.org/cn/install.sh | bash

Vim Configuration 02 Nvim的插件配置

Vim Configuration 02 Nvim的插件配置

@Aikenhong 2021

Vim is a important consistant for editing file in shell. It’s Hightly Customized for Everyone, In this part I’ll Show my personal Vim comfigurations

And I’ll Discuss about the diff between Spacevim & Neovim.

Give a conclusion in advance: Recommand Config the Vim for Yourself

  • You only need to config once, then you should save it in the cloud.
  • You will Know all the Keyshot you setting up, and you can customize it as you want.

image-20211014192437083

Based on neovim

基于NeoVim进行配置,不采用SpaveVim的配置文件,这里需要建议采用最新的测试版的NeoVim(>= 0.5),Stable的NVim已经很久没有更新,对一些新的插件缺乏支持。

Install

Installing Neovim Download NeoVim Package and Install from source

or Install from neovim-ppa Like Following:

1
2
3
sudo add-apt-repository ppa:neovim-ppa/unstable
sudo apt-get update
sudo apt-get install neovim

Vim Configuration 01 vim的无插件基础设置

Vim Configuration 01 vim的无插件基础设置

该配置笔记于 20230521 重新整理。默认的 Vimrc 位置为 /usr/share/vim/vimrc,也可以在 vim 界面使用 :echo $MYVIMRC 查看当前的配置文件,默认使用的配置文件地址为 ~/.vimrc

参考文献地址:Good VimRC | Backspace | AutoCmd | VIM配置入门
配置文件地址:AikenDotfile,本文这里只介绍部分配置,一些过于常见的配置等等这里就不再介绍,在 dotfile 中对每行配置均有的细致的注释。

基于 VimScript) 该 blog 主要记录基础 vim 的配置文件编写,旨在使用基础 vim 的时候也能有一个较好的代码编辑体验,同时提供部分 keymap 集成一些简单的功能,方便文档编写时候的格式转换等。这个配置文件在后续配置 nvim 的时候部分配置也会沿用。

Vim 的基础配置

自动检测文件修改,以及对多个文件的 workspace 自动切换

1
2
3
" >>0-1 state detection.
set autoread " when file change outside, we will know
set autochdir " change workspace when we swtich file, when we open multi-file in one session.

鼠标和剪切板功能

设置 vim 对鼠标的支持,支持鼠标选择等

1
2
3
4
5
6
" reference the web get the best setting and use it always
" suppose the mouse operation
" but this function not work well in the weterm, we disable this part for work.
set mouse=a
"set selection=exclusive
"set selectmode=mouse,key

设置和系统同步的剪切板,WSL 下的剪切板设置可以参考下面文章 WSL2 clipboard not shared between Linux and Windows || Reddit - Dive into anything

1
2
3
4
5
6
7
8
9
10
11
12
" set the clipboard
set clipboard+=unnamed

" WSL yank support
let s:clip = '/mnt/c/WINDOWS/system32/clip.exe' " change this path according to your mount point
if executable(s:clip)
augroup WSLYank
autocmd!
autocmd TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif
augroup END
endif

设置撤销历史记录

多次编辑同一个文件的时候保持 Undo 的历史记录,便于对同一个文件进行编辑。

1
2
3
4
" >>0-2 keep file history
set undofile " keep the undo history in file.
set undodir=~/.vim/.undo//
set history=1000

通过上述命令启用 undofile 的选项,并设置存储目录,这里需要注意的是,存储目录需要手动创建,undo 的历史记录才能生效。