Created
May 29, 2015 14:40
-
-
Save yanick/219e179e97c383851f12 to your computer and use it in GitHub Desktop.
VimX unicode picker
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
use Vim::X; | |
use App::Uni; | |
use 5.20.0; | |
use strict; | |
no warnings; | |
sub UnicodePicker :Vim(args) { | |
my @result = map { [ split /\s*-\s*/, $_, 3 ] } | |
split "\n", `uni $_[0]`; | |
splice @$_, 2, 0, hex($_->[1] =~ s/U\+//r) for @result; | |
my $prompt = join "\n", "0 - nevermind", map { | |
join ' - ', $_+1, @{$result[$_]} | |
} 0..$#result; | |
$prompt .= "\n"; | |
my $answer = vim_input $prompt or return; | |
my $char = $result[$answer-1]; | |
if ( my $dig = $_[1] ) { | |
vim_command "dig $dig ". $char->[2]; | |
vim_msg "digraph $dig set as " . $char->[3]; | |
} | |
else { | |
vim_line->content( vim_line->content . $char->[0] ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment