vim related notes - Serbipunk/notes GitHub Wiki
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
top line gg last line G
:set noai nocin nosi inde=
CTRL-o
and CTRL-i
在 Vim 中替换字符串可以使用 :s 命令。具体步骤如下:
进入 Vim 编辑器并进入命令模式,即按下 Esc 键。
输入 :%s/old/new/g,其中 old 是要被替换的字符串,new 是替换成的新字符串。
按下回车键,Vim 会将文档中所有匹配的字符串全部替换成新的字符串。
bin2hex
:%!xxd
hex2bin
:%!xxd -r
- Place the cursor on the line you want to begin cutting.
- Press V to select the entire line, or v to select from where your cursor is.
- Move the cursor to the end of what you want to cut, using h,j,k, or l
- Press y to copy it, or d to cut it.
- Place the cursor where you would like to paste your copied stuff.
- Press P to paste it before your cursor, or p to paste it after the cursor.
ctrl + o
ctrl + i
ctrl + e 向上滚一行(fix cursor at curtain line, just scroll screen line by line)
ctrl + y 向下滚一行 (same as ctrl + e)
ctrl + u 向上滚半屏
ctrl + d 向下滚半屏
undo: u re-undo: ctrl + r
yy + p dumplicate n line
nyy + p n = 1, 2, 3, 4...
:edit!
:split
:split xxx(要打开的文件名)
:join
<CTRL+W> k:跳转到上面的窗口 (若为大写K,则是把当前窗口调至上方)
<CTRL+W> j:跳转到下面的窗口 (类似于上)
command mode 'b'
filetype plugin indent on
set tabstop=4
set shiftwidth=4
set expandtab
auto indenting: set autoindent
https://stackoverflow.com/questions/2462794/indent-or-comment-several-text-lines-with-vi https://stackoverflow.com/questions/1676632/whats-a-quick-way-to-comment-uncomment-lines-in-vim
:set hlsearch
/search world
:nohlsearch
With the CTRL-O and CTRL-I command you can go to cursor positions before older jumps, and back again
set number
set tabstop=2
set autoindent
set expandtab
set hlsearch
ctrl + #
cmd | vim -
https://stackoverflow.com/a/9549765
1 move to position
2 ctrl + v
(visual block mode)
3 jump to pos
4 I
5 edit
6 Esc