vim - linchuan1982/meta GitHub Wiki

字符串查找和替换

http://xstarcd.github.io/wiki/vim/vim_replace_encodeing.html

规则

作用范围 | from | to | 每行的规则 | confirm

  •   				| - 	| - 	| - 			| -
    

.,$s 从当前行到最后一行 | # | | g:替换本行所有匹配 | c %s 所有行 | / | | | s 当前行 | + | | |

:.,$s/abc/efg/gc

  1. .,$ 指定执行的范围为从当前行到最后
  2. 最后的g表示当前行所有匹配,不然则只会替换第一个
  3. 最后的c表示confirm,需要确认
  4. 分隔符有三种:/, #, + 遇到特殊字符用其他两个来代替

:%s#//#/#gc

替换文件中所有的///

禁用括号匹配

" Disable parentheses matching depends on system. This way we should address all cases (?)
set noshowmatch
" NoMatchParen " This doesnt work as it belongs to a plugin, which is only loaded _after_ all files are.
" Trying disable MatchParen after loading all plugins
"
function! g:FuckThatMatchParen ()
    if exists(":NoMatchParen")
        :NoMatchParen
    endif
endfunction

augroup plugin_initialize
    autocmd!
    autocmd VimEnter * call FuckThatMatchParen()
augroup END