Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
~除了切换大小写之外,什么是扩展 Vim 中(波浪号)键功能以反转文本中的 1 和 0 的好方法?
也就是说,如果我的光标在正常模式下位于 0 或 1 上,并且我想~将其转换为 1 或 0(分别),那么在不改变字母字符的正常行为(大写/小写交换)?
快速浏览:help ~说“不”。您可能必须编写一个小函数并将其映射到~:
:help ~
~
function! BinSwitch() let current_char = getline(".")[col(".") - 1] if current_char == "0" normal! r1 elseif current_char == "1" normal! r0 else normal! ~ endif endfunction nnoremap ~ :silent call BinSwitch()<cr>