From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id c285c5a3 for ; Wed, 8 Jan 2020 21:57:02 +0000 (UTC) Received: (qmail 19201 invoked by alias); 8 Jan 2020 21:56:55 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24609 Received: (qmail 4261 invoked by uid 1010); 8 Jan 2020 21:56:55 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f178.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25684. spamassassin: 3.4.2. Clear:RC:0(209.85.208.178):SA:0(-2.0/5.0):. Processed in 0.829632 secs); 08 Jan 2020 21:56:55 -0000 X-Envelope-From: butirsky@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.208.178 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=oKVmgXHHXCbKucS3z2+hIJkwC3ijj7L9NrAhOlt/e1I=; b=PE0bhkjHG4ZWiCGpT/Bk6t6qBEWHTGQKypNopsMmOWpYwPpGR37+Y+VMCpz9kg79/z dVGOsk6WB79oj0g1xkIFpPOZOrKIY83A9P5nx5zQ/zze6N+i4R/SBNBR2HTdPkany02K RbesLeyNmQ4j2LLMAhS82WYPYbFrk7NHReCrowUGzJ8/yE+7R5tdPmIaK8vOpeHzI0ZJ bFnNhVAZVv+OXiLUW1i3Wcj88XspwwJYLlxfCaVSRiXB98woqMh7igkbJLnaJLfWmk+f Y2iVhQLSAERVFGaRCD/WrSuEWi6hF1lHwGPjklsKQGM1DV5+gACIrsuSk13mpzTv9Bvw F4rQ== X-Gm-Message-State: APjAAAXFxuMaAEj/GgRgzCHcjL/wPKlJvS1ieLCcnC90lejFNoiwD2WV /g/a6iaouxZnVX4JIbierC3WAJlf X-Google-Smtp-Source: APXvYqzGwwYufg1RBt7hHR80MgiTaRm542R2BLbpIpWmXxeJw+EIfIyj8mYBgbjTsLRL9J4KkQ62GQ== X-Received: by 2002:a2e:9cd8:: with SMTP id g24mr4116728ljj.243.1578520580332; Wed, 08 Jan 2020 13:56:20 -0800 (PST) Subject: Re: emulate bash key bindings To: zsh-users@zsh.org References: <1578477603.6726.5.camel@samsung.com> From: Andrey Butirsky Message-ID: <3e056cff-f690-f416-d8b6-89059c64187a@gmail.com> Date: Thu, 9 Jan 2020 00:55:58 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Thunderbird/72.0 MIME-Version: 1.0 In-Reply-To: <1578477603.6726.5.camel@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US On 08.01.2020 13:00, Peter Stephenson wrote: > On Tue, 2020-01-07 at 21:38 +0300, Andrey Butirsky wrote: >> Hello, >> >> after 25 years of bash, I'm doing my first steps with Zsh. >> >> I'm trying to reproduce main bash key bindings in Zsh, so I started with: >> >> autoload -U select-word-style >> select-word-style bash >> >> But sill, I need to have different word boundaries for some bindings, >> e.g Ctrl+W should kill space-delimeted word. >> >> What is the best way to achieve that? Can I avoid creating custom widgets? > The most configurable way is to use the special widget, the same one > that you've now got bind to the usual backward-kill-word functions, but > under a different name.  Then you can set a special style for the > behaviour.  Then you have all the same possibilities as the widget > functions at your fingertips, without having to redefine any functions. > > > # Create widget backward-kill-space-word, using the generic > # backward-kill-word widget function. > zle -N backward-kill-space-word backward-kill-word-match > # Tell it to use "space" style for words. > zstyle ':zle:backward-kill-space-word:*' word-style space > # Bind it. > bindkey '^W' backward-kill-space-word > > > The zshcontrib manual lists the various styles. > > pws > Thanks to all for answering! Actually, the solution with styles is what I came to myself, just used aliases instead of creating new widgets (zle -A forward-word space-forward-word). But binding with dot-prefixed widget names seem the most compact solution for me: "bindkey '^w' .backward-kill-word", thanks! Still, both solutions do not seem very obvious, at least for new user. So maybe we should emphasize it in the documentation? I think a few extra examples in section introducing 'select-word-style' command would be enough.