作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想要正常模式命令波浪号 ~
,除了改变字母的大小写,还可以改变文字 ==
至 !=
和 !=
至 ==
.
我发现我经常这样做,我想要一个仍然使用波浪号的快捷方式。
最佳答案
这在 vimscript 中相当简单。
将以下内容添加到您的 .vimrc
或 source
此代码来自不同的文件。
" ----------------------
" Tilde switches ==/!=
" ----------------------
function! TildeSwitch()
" Gets the pair of characters under the cursor, before and behind.
let cur_pair = getline(".")[col(".") - 2 : col(".") - 1]
let next_pair = getline(".")[col(".") - 1 : col(".")]
if cur_pair == "=="
normal! "_ch!
normal! l
elseif next_pair == "=="
normal! r!
elseif cur_pair == "!="
normal! "_ch=
normal! l
elseif next_pair == "!="
normal! r=
else
" If == and != are not found, simply use the regular tilde.
normal! ~
endif
endfunction
nnoremap <silent> ~ :silent call TildeSwitch()<cr>
关于vim - 如何让 Vim 中的波浪号运算符将 ‘==’ 更改为 ‘!=’?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14691620/
我是一名优秀的程序员,十分优秀!