拉丁语言的单词交换映射
Vim Wiki上的单词交换映射在带有重音字符的单词上无法正确运行。
这些映射适用于使用(欧洲)ISO / IEC_8859-1 Latin-1补码字符。这可以通过替换\w
with的[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-]
所有实例和\_W
with的所有实例来完成\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-]
。
清除搜索突出显示
此外,在需要的地方清除了搜索突出显示的内容。这是通过:nohlsearch<return>
在需要时在每个映射的末尾添加来实现的。
这是最终结果:
" Use gc to swap the current CHARACTER with the next, WITHOUT changing the cursor position.
nnoremap <silent> gc xph
" Use gw to swap the current WORD with the next, WITHOUT changing the cursor position.
nnoremap <silent> gw "_yiw:s/\(\%#[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\(\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\([0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)/\3\2\1/<CR><c-o><c-l>:nohlsearch<return>
" Disable Alt+[menukey] menu keys (i.e. Alt+h for help)
set winaltkeys=no
" Use Alt + ← or Alt + h to swap the current WORD with the previous, keeping the cursor on the current word. This feels like "PUSHING" the word to the left.
nnoremap <silent> <A-Left> "_yiw?[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-]\+\%#<CR>:s/\(\%#[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\(\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\([0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)/\3\2\1/<CR><c-o><c-l>:nohlsearch<return>
nnoremap <silent> <A-h> "_yiw?[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-]\+\%#<CR>:s/\(\%#[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\(\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\([0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)/\3\2\1/<CR><c-o><c-l>:nohlsearch<return>
" <A-h> corresponds to è
" Use Alt + → or Alt + l to swap the current WORD with the next, keeping the cursor on the current word. This feels like "PUSHING" the word to the right.
nnoremap <silent> <A-Right> "_yiw:s/\(\%#[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\(\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\([0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)/\3\2\1/<CR><c-o>/[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+<CR><c-l>:nohlsearch<return>
nnoremap <silent> <A-l> "_yiw:s/\(\%#[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\(\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)\([0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\)/\3\2\1/<CR><c-o>/[0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+\_[^0-9A-Za-zÀ-ÖØ-öø-ÿ_\-\`]\+<CR><c-l>:nohlsearch<return>
" <A-l> corresponds to ì
" Use g{ to swap the current PARAGRAPH with the next.
nnoremap g{ {dap}p{