Vim

配置:https://vimhelp.org/options.txt.html & https://ruanyifeng.com/blog/2018/09/vimrc.html

sudo vim /etc/vim/vimrc.local

" cat /etc/vim/vimrc,https://www.preining.info/blog/2017/10/fixing-vim-in-debian
if filereadable("/usr/share/vim/vim90/defaults.vim")
  source /usr/share/vim/vim90/defaults.vim
endif
let g:skip_defaults_vim = 1
" 禁用提示音
set noerrorbells
set visualbell
set t_vb=
" 不生成 ~/.viminfo
set viminfo=
" 显示行号,set nu/nonu
set number
" 不与 Vi 兼容
set nocompatible
" 语法高亮
syntax enable
" 在底部显示,当前处于命令模式还是插入模式
set showmode
" 使用 utf-8 编码
set encoding=utf-8
" 启用256色
set t_Co=256
" 开启文件类型检查,并且载入与该类型对应的缩进规则。比如,如果编辑的是.py文件,Vim 就是会找 Python 的缩进规则
filetype indent on
" 按下回车键后,下一行的缩进会自动跟上一行的缩进保持一致
set autoindent
" 光标所在的当前行高亮
set cursorline
" 是否显示状态栏。0 表示不显示,1 表示只在多窗口时显示,2 表示显示
set laststatus=2
" 在状态栏显示光标的当前位置(位于哪一行哪一列)
set ruler
" 鼠标设置
set mouse=

 

快捷键(vim cheat sheet):https://cenalulu.github.io/linux/all-vim-cheatsheat & https://github.com/Michaelangel007/vim_cheat_sheet

 

主题:https://github.com/vim/colorschemes & https://vimcolorschemes.comhttps://vimcolors.org

 

从标准输入读取:https://vimhelp.org/usr_26.txt.html#26.4

ls / | vim -
strace -f gcc a.c 2>&1 | vim -
strace -f gcc a.c |& vim -
strace -f gcc a.c 2>&1 | tee /dev/tty | vim -

 

执行命令

# 不退出 vim 执行命令,不改变当前编辑内容
:! pwd

# 将命令结果插入到当前行的下一行
:r ! date

# 将1-3行内容排序并替换原内容
:1,3 ! sort
# 将第 1 行中小写转大写
:1 ! tr [a-z] [A-Z]
# 将当前光标所在行中小写转大写
:. ! tr [a-z] [A-Z]
# 5-最后一行
:5,$ ! tr [a-z] [A-Z]
# 全文小写改大写
:,$ ! tr [a-z] [A-Z]
# 全文小写改大写
:%!tr a-z A-Z

# 将1-3行内容进行排序,不替换原内容,结果显示在 vim 命令区域
:1,3 w !sort

# 第1行内容作为命令执行,不替换原内容,结果显示在 vim 命令区域
:1 w !bash
# 类似的,将当前行内容作为命令执行
:. w !bash

 

十六进制编辑

sudo apt install -y xxd
# 打开
vim -b a.out
# 转为十六进制编辑。注意这里的编辑只能作用于左侧的十六进制内容
:%! xxd
# 编辑后转回文本
:%! xxd -r
# 保存
:x

 


https://www.vim.org/docs.php

https://vimhelp.org & https://yianwillis.github.io/vimcdoc

https://coolshell.cn/articles/5426.html

posted @ 2019-03-21 18:57  江湖小小白  阅读(1163)  评论(0)    收藏  举报