Skip to content

Instantly share code, notes, and snippets.

@yanick
Created May 29, 2015 14:40
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 yanick/219e179e97c383851f12 to your computer and use it in GitHub Desktop.
Save yanick/219e179e97c383851f12 to your computer and use it in GitHub Desktop.
VimX unicode picker
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