-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2ece48c
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# zenkaku.vim | ||
Adds commands to find and replace zenkaku characters with normal character equivalents. | ||
|
||
[wtf is a zenkaku?](https://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms_\(Unicode_block\)) | ||
|
||
## Features | ||
The plugin adds the following commands: | ||
|
||
| Command | Effect | | ||
| -------------------- | ------------------------------------------------------------------------ | | ||
| `:FixZenkakuDigits` | Replace all zenkaku digits with ascii equivalents | | ||
| `:FixZenkakuUpper` | Replace all zenkaku upper-case with ascii equivalents | | ||
| `:FixZenkakuLower` | Replace all zenkaku lower-case with ascii equivalents | | ||
| `:FixZenkakuOthers` | Replace all zenkaku special characters with ascii equivalents | | ||
| `:FixZenkakuLetters` | Combine `:FixZenkakuLower` and `:FixZenkakuUpper` | | ||
| `:FixZenkaku` | Combine `:FixZenkakuDigits`, `FixZenkakuLetters` and `:FixZenkakuOthers` | | ||
|
||
## Installation | ||
As with most vim plugins, [vim-plug](https://github.com/junegunn/vim-plug) is a handy way to | ||
install it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
" vim:set ft=vim et sw=2: | ||
let s:digits = [ | ||
\ ['0', '0'], ['1', '1'], ['2', '2'], ['3', '3'], ['4', '4'], | ||
\ ['5', '5'], ['6', '6'], ['7', '7'], ['8', '8'], ['9', '9'], | ||
\] | ||
|
||
let s:upper = [ | ||
\ ['A', 'A'], ['B', 'B'], ['C', 'C'], ['D', 'D'], ['E', 'E'], | ||
\ ['F', 'F'], ['G', 'G'], ['H', 'H'], ['I', 'I'], ['J', 'J'], | ||
\ ['K', 'K'], ['L', 'L'], ['M', 'M'], ['N', 'N'], ['O', 'O'], | ||
\ ['P', 'P'], ['Q', 'Q'], ['R', 'R'], ['S', 'S'], ['T', 'T'], | ||
\ ['U', 'U'], ['V', 'V'], ['W', 'W'], ['X', 'X'], ['Y', 'Y'], | ||
\ ['Z', 'Z'], | ||
\] | ||
|
||
let s:lower = [ | ||
\ ['a', 'a'], ['b', 'b'], ['c', 'c'], ['d', 'd'], ['e', 'e'], | ||
\ ['f', 'f'], ['g', 'g'], ['h', 'h'], ['i', 'i'], ['j', 'j'], | ||
\ ['k', 'k'], ['l', 'l'], ['m', 'm'], ['n', 'n'], ['o', 'o'], | ||
\ ['p', 'p'], ['q', 'q'], ['r', 'r'], ['s', 's'], ['t', 't'], | ||
\ ['u', 'u'], ['v', 'v'], ['w', 'w'], ['x', 'x'], ['y', 'y'], | ||
\ ['z', 'z'], | ||
\] | ||
|
||
let s:others = [ | ||
\ ['!', '!'], ['"', '"'], ['#', '#'], ['$', '$'], ['%', '%'], | ||
\ ['&', '\&'], ["'", "'"], ['(', '('], [')', ')'], ['*', '*'], | ||
\ ['+', '+'], [',', ','], ['-', '-'], ['.', '.'], ['/', '\/'], | ||
\ [':', ':'], [';', ';'], ['<', '<'], ['=', '='], ['>', '>'], | ||
\ ['?', '?'], ['@', '@'], ['[', '['], ['\', '\'], [']', ']'], | ||
\ ['^', '^'], ['_', '_'], ['`', '`'], ['{', '{'], ['|', '|'], | ||
\ ['}', '}'], ['~', '~'], ['⦅', '«'], ['⦆', '»'], ['。 ', '.'], | ||
\ ['、 ', ','], ['ー ', '-'], ['] ', ']'], ['¢', '¢'], ['£', '£'], | ||
\ ['¥', '¥'], ['₩', '₩'], | ||
\] | ||
|
||
function s:ReplaceWithMap(replacementMap) | ||
for pair in a:replacementMap | ||
execute '%s/\C' . pair[0] . '/' . pair[1] . '/g' | ||
endfor | ||
endfunction | ||
|
||
command FixZenkakuDigits call s:ReplaceWithMap(s:digits) | ||
command FixZenkakuUpper call s:ReplaceWithMap(s:upper) | ||
command FixZenkakuLower call s:ReplaceWithMap(s:lower) | ||
command FixZenkakuOthers call s:ReplaceWithMap(s:others) | ||
|
||
command FixZenkakuLetters | ||
\ execute 'FixZenkakuUpper' | ||
\ | execute 'FixZenkakuLower' | ||
|
||
command FixZenkaku | ||
\ execute 'FixZenkakuDigits' | ||
\ | execute 'FixZenkakuLetters' | ||
\ | execute 'FixZenkakuOthers' |