Skip to content

Instantly share code, notes, and snippets.

@slimane
Created September 24, 2013 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slimane/6682815 to your computer and use it in GitHub Desktop.
Save slimane/6682815 to your computer and use it in GitHub Desktop.
全角文字は死ね
command! FullToHalf call s:full_to_half.substitute()
let s:full_to_half = {}
let s:full_to_half.table = {
\ ' ' : ' '
\ , '(' : '('
\ , ')' : ')'
\ , ':' : ':'
\ , '0' : '0'
\ , '1' : '1'
\ , '2' : '2'
\ , '3' : '3'
\ , '4' : '4'
\ , '5' : '5'
\ , '6' : '6'
\ , '7' : '7'
\ , '8' : '8'
\ , '9' : '9'
\ }
function! s:full_to_half.substitute() dict
let substitute_list =
\ values(map(deepcopy(self.table)
\ , '":silent %s/" . v:key . "/" . v:val . "/ge"'))
call s:bleiben_execute(substitute_list)
endfunction
function! s:bleiben_execute(cmd_list)
let l:pos = getpos('.')
for cmd in a:cmd_list
execute cmd
endfor
call setpos('.', l:pos)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment