vim

Posted on Jan 1, 1

参考

参考 [[sed]] http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/ 非常好的入门材料

简明 VIM 练级攻略

http://yannesposito.com/Scratch/en/blog/Vim-as-IDE/

安装vim插件 https://opensource.com/article/20/2/how-install-vim-plugins

无插件VIM编程技巧

你可以看看《简明vim攻略》和 《Vim的冒险游戏》以及《给程序员的Vim速查卡》还有《把Vim变成一个编程的IDE》等等。

http://neovim.io/doc/user/quickref.html

image.png{:height 570, :width 727}

安装插件

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

:PlugInstall

命令

image.png{:height 609, :width 778} Zone selection   <action>a<object>   or   <action>i<object> The object can be:  w  a word,  W  a WORD (extended word),  s  a sentence,  p  a paragraph. But also, natural character such as  "')}] .

keys #hotkey

<start position><command><end position>

N → will repeat the command N times. <C-r>  → redo P  → paste before, remember  p  is paste after current position. :bn  (resp.  :bp ) → show next (resp. previous) file (buffer) w  → go to the start of the following word, e  → go to the end of this word. %  : Go to the corresponding  ({[ . *  (resp.  # ) : go to next (resp. previous) occurrence of the word under the cursor y  (yank), is also true for  d  (delete),  v  (visual select),  gU  (uppercase),  gu  (lowercase) 自动补全 Completion:   <C-n>   and   <C-p> . Macros :   qa   do something   q ,   @a ,   @@ qa  record your actions in the register  a . Then  @a  will replay the macro saved into the register  a  as if you typed it.  @@  is a shortcut to replay the last executed macro. Visual selection:   v , V , <C-v> J  → join all the lines together. <  (resp.  > ) → indent to the left (resp. to the right). =  → auto indent 窗口管理 Splits:   :split   and   vsplit . (sp,vsp) :split  → create a split ( :vsplit  create a vertical split) <C-w><dir>  : where dir is any of  hjkl  or ←↓↑→ to change the split. <C-w>_  (resp.  <C-w>| ) : maximise the size of the split (resp. vertical split) <C-w>+  (resp.  <C-w>- ) : Grow (resp. shrink) split 使用窗口编号切换:Vim 给每个窗口分配了一个唯一的编号。要切换到特定的窗口,可以按下 <窗口编号>。例如,要切换到窗口 2,你可以按下 2。

使用方向键切换:你可以使用 <方向键> 来在窗口之间切换。例如,按下 <向上箭头> 将切换到上方的窗口,按下 <向下箭头> 将切换到下方的窗口,以此类推。

使用 :wincmd 命令切换:使用 :wincmd 命令可以在不同的窗口之间进行切换。命令格式是 :wincmd <方向键>。例如,要切换到下方的窗口,可以执行命令 :wincmd j。

使用 切换:按下两次 将切换到下一个窗口。你可以重复按下这个组合键,以在不同的窗口之间进行循环切换。

使用 :snext 和 :sprevious 命令切换::snext 命令将切换到下一个窗口,:sprevious 命令将切换到上一个窗口。你可以在命令模式下执行这些命令。

写入只读文件

w !sudo tee % >/dev/null

插入文件

:r /path/to/file

term

打开一个terminal

set

Why is VIM starting in replace mode?

set t_u7=
" set ambw=double

set number

set all 查看所有选项

paste模式

:set paste

显示eol和编码

# 显示eol
set list
set fileencoding?

大小写查询 How to do case insensitive search in Vim

/\c来表示大小写不敏感 \C大小写敏感

:set ic
:set noic

echo "set ic" >> ~/.vimrc
:help ignorecase