is beside the emacs mode also a vi/vim mode available ?

107 views
Skip to first unread message

Peace Keeper

unread,
Nov 5, 2020, 3:50:39 PM11/5/20
to BBEdit Talk
So there is a emacs key binding available in bbedit. As I am using diffrent ux systems, the common instant available editor is vi. There is no compilation needed etc.
So I am used to use keystrokes like gg or G  or hjkl to move around or 5dd to delet the next 5 lines. On macOS I switch over to BBedit as I know it still from System7 and it was/is a gorgeous editor on a mac. So I wonder if emacs shortcuts are available, there might be also vi shortcuts ?
Or at least an idea how to setup ?

Patrick Woolsey

unread,
Nov 5, 2020, 4:05:08 PM11/5/20
to bbe...@googlegroups.com
I regret there are no shortcuts for vi as it's just not feasible
to map the requisite key handling and modality onto BBEdit's
native behaviors.

Regards

Patrick Woolsey
==
Bare Bones Software, Inc. <https://www.barebones.com/>

Peace Keeper

unread,
Nov 5, 2020, 4:33:05 PM11/5/20
to BBEdit Talk
Ha, but for emacs  <grummel>

<stop kidding>  I understand, emacs has a lot of meta keys, that make it easy to implement in other apps as these key combinations are rarely used elsewhere.
Thanks for the clear answer - that save time by stop searching around.

Too bad, that I can't use bbedit from a remote tmux session to initiate an edit of a local file on a remote server. Seems I still have to initiate that from macOS

Charlie Garrison

unread,
Nov 5, 2020, 5:38:18 PM11/5/20
to BBEdit Talk

On 6 Nov 2020, at 8:30, Peace Keeper wrote:

Too bad, that I can't use bbedit from a remote tmux session to initiate an edit of a local file on a remote server. Seems I still have to initiate that from macOS

It's not the actual editor, but rbbedit will help with editing files using BBEdit, that you have on remote servers.

-cng

--

Charlie Garrison                   <cha...@garrison.com.au>
Garrison Computer Services      <http://www.garrison.com.au>
PO Box 380
Tumbarumba NSW 2653  Australia

Peace Keeper

unread,
Nov 6, 2020, 8:43:51 AM11/6/20
to BBEdit Talk
Thanks Charlie,

I have read some threads here in the forum about rbbedit. I just looked through the code on github and it is a nice script. I think for me a one-liner with scp might be enough. On the other side I think about changing my workflow a bit. As I am using anyhow tmux from the macOS with bbedit installed, Only challenge are files owned by root as I don't allow ssh connection for root. But I could change my workflow to use first git and push the file to my Mac as remote, then make changes with bbedit on my private "github" on my make includeing a checkin, then initate a git pull from remote. This workflow would bring me some additional improvments: all files are versioned, all files are backuped, a centralized repository for distributing the changes to all other server would be available.

As I understand that BareBones is focusing on the macOS, a bbedit-daemon on  remote systems would be  a nice feature and might be needed anyhow in the future: if people switch from laptop to tablets only , they will program/work directly on the remote machines using the tablet only as a front-end ( Something like a dump terminal with some local features)  In this case. In a CI and CD environment that would be a nice feature. 

Steve deRosier

unread,
Nov 6, 2020, 11:25:10 AM11/6/20
to bbedit
I can't speak for rbbedit, but I do pretty much the same thing with a
simple set of lines in my .bashrc:

export REMOTEHOST=`echo $SSH_CLIENT | cut -d ' ' -f 1`
export HOSTIP=`echo $SSH_CONNECTION | cut -d ' ' -f 3`

function bbedit {

# bbedit won't open a remote file via sftp if it doesn't
exist. So, if it's a new file
# create it, call bbedit to open, and then kill it.
FCREATED=0
if [ ! -e "$PWD/$1" ]
then
touch "$PWD/$1"
FCREATED=1
fi

ssh $USER@$REMOTEHOST /usr/local/bin/bbedit -c -u
--front-window "sftp://$USER@$HOSTIP/$PWD/$1"

# The above call will background and return immediately. The
file will open in bbedit
# but since we've created it, and we don't want to leave it
around, we kill it right away.
# If the user saves it, it gets recreated and content is
saved. If not, there's no file,
# so we're cool too. It's a bit odd, but it works.
if [ "$FCREATED" -eq "1" ]
then
rm "$PWD/$1"
fi
}

And then I just `bbedit file.txt` all day long. I spend all day ssh'd
into Linux boxes editing kernel code and embedded Linux systems. I
expect there's many ways to do this and make it compatible with sudo
if you tinkered sufficiently. Note for cscope to work, you actually
need a script. I have this and then I set my CSCOPE_EDITOR to the
path:
$ cat ~/bin/bbeditcscope
#!/bin/bash
# $1 : Line number from cscope in +## format
# $2 : File name, relative to cscope's location
ssh $USER@$REMOTEHOST /usr/local/bin/bbedit --front-window $1
"sftp://$USER@$HOSTIP/$PWD/$2"

I probably would've used rbbedit if it had existed when I started
doing this, but the above works well for me and I've never had a
reason to change my method.

- Steve
> --
> This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
> ---
> You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/4ae46a8d-38c4-4388-8d78-76963208c6bfn%40googlegroups.com.

Peace Keeper

unread,
Nov 7, 2020, 9:10:15 AM11/7/20
to BBEdit Talk
Thanks Steve !

interesting how you handle the "new file" creation. I was under the impression that bbedit could override it via sftp/scp. Another challenge is the handling after "sudo su - toor" as then all SSH information is gone. ( Some applications can't handle sudo - especially when an error occurred and - from a user point of view - sudo is stuck. So I am using the ZSH customised toor user for these root actions.
There might be a possibility to use sudoedit instead a complete switch to toor, but that would also mean taht I need to wrap your scripting in something like rbbedit as sudoedit is calling SUDO_EDITOR ...
Anyhow, good to know there are some workarounds available, while BareBones is not supporting such a use case out of the box.

Charlie Garrison

unread,
Nov 8, 2020, 5:58:55 PM11/8/20
to BBEdit Talk

Good morning,

I didn't really follow your use-case (is it just issue with root-owned files). rbbedit is effectively a wrapper for ssh/scp and bbedit commands.

You talk about both a "simple one-liner" and "change of workflow" in one paragraph. Yes, rbbedit is more than one line underneath, so that it can become that 'one-liner' for different people on different servers. For me, a manual one-liner would have to be adapted for many of the different servers I use, but rbbedit is consistent across all of them.

I did change my workflow for rbbedit, but overall it's a simpler workflow.

For root-owned files, you should be able to use the scp 'copy method' with rbbedit, but the --wait flag is enforced so not best for all cases. Otherwise, I've been known to create a temp copy with changed user ownership, and use rbbedit to edit the temp file. I’m not recommending that though since it's not a safe thing to do in many cases. Safely editing root-owned files is a "big topic".

So if your issue is editing root-owned files without allowing root access, then rbbedit is not the tool you seek. If you find a "safe" solution, I would be keen to hear about it and maybe add to rbbedit.

-cng

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/4ae46a8d-38c4-4388-8d78-76963208c6bfn%40googlegroups.com.

Charlie Garrison

unread,
Nov 8, 2020, 6:06:31 PM11/8/20
to bbedit

Good morning,

On 7 Nov 2020, at 3:24, Steve deRosier wrote:

I probably would've used rbbedit if it had existed when I started
doing this, but the above works well for me and I've never had a
reason to change my method.

Yep, that's what rbbedit does (minus new file creation; I'll have to add that), but just abstracts away many of the finer details so it's easy to install and use on lots of servers.

I'm curious, how long have you been using your scripts? rbbedit is still young compared to BBEdit, but it's far from being an infant:

Initial commit
cngarrison committed on 3 Sep 2014

Steve deRosier

unread,
Nov 8, 2020, 7:49:10 PM11/8/20
to bbedit
On Sun, Nov 8, 2020 at 3:06 PM Charlie Garrison
<charlie...@garrison.com.au> wrote:
>
> Good morning,
>
> On 7 Nov 2020, at 3:24, Steve deRosier wrote:
>
> I probably would've used rbbedit if it had existed when I started
> doing this, but the above works well for me and I've never had a
> reason to change my method.
>
> Yep, that's what rbbedit does (minus new file creation; I'll have to add that), but just abstracts away many of the finer details so it's easy to install and use on lots of servers.
>
> I'm curious, how long have you been using your scripts? rbbedit is still young compared to BBEdit, but it's far from being an infant:

Honestly, I can't even remember. I've been using BBEdit in some form
for > 20 years. Best guess, I started using the .bashrc function and
bbeditcscope script > 10-12 years ago. For a long time I was making
very heavy use of sshfs/fuse or nfs mounting also, so that my files
just looked like "local" files. Lately not so much, relying much more
heavily on the sftp functions of BBEdit, especially as I'm relying
more and more on VPN access to central development servers.

Primary development use case: embedded Linux, so lots of work on Linux
drivers (C, DTS), build systems like OpenWRT and Buildroot (make and
CMake files), WiFi firmware, Python utilities and frameworks. I tend
to dislike IDEs as embedded doesn't lend itself well to that model.

- Steve

Peace Keeper

unread,
Nov 9, 2020, 8:32:30 AM11/9/20
to BBEdit Talk
Hey Charlie,

thanks for your comments. Yes, it is mainly for root files. For user files I could use rbbedit or the build-in remote functionalities from bbedit - just triggered by bbedit from macOS instead of my server shell. ( Of course I would prefer an official support from BareBone for the remote triggered use-case)
I don't allow passwd or any root access to my server via sxx suite. Of course sudo is possible on the server and edit with vi the files on that platform. But I could also not trigger the editing from bbedit ( as no root login allowed). I am not sure if - from a security point of view - a daemon on the server and macOS would solve this dilemma .
Anyhow, knowing that for that case I might still need to use vi is not really a trouble - its not my daily job.

Charlie Garrison

unread,
Nov 9, 2020, 5:32:15 PM11/9/20
to bbedit

Good morning,

On 9 Nov 2020, at 11:48, Steve deRosier wrote:

On Sun, Nov 8, 2020 at 3:06 PM Charlie Garrison
charlie...@garrison.com.au wrote:

I'm curious, how long have you been using your scripts? rbbedit is still young compared to BBEdit, but it's far from being an infant:

Honestly, I can't even remember. I've been using BBEdit in some form
for > 20 years. Best guess, I started using the .bashrc function and

...

That all sounds VERY familiar. :-D

rbbedit even has support for fuse (via ExpanDrive) since that was my primary way to access servers for a while. I use sftp in BBEdit "all the time" now, but I trigger it via rbbedit (which of course uses bbedit to do the work).

Primary development use case: embedded Linux, so lots of work on Linux
drivers (C, DTS), build systems like OpenWRT and Buildroot (make and
CMake files), WiFi firmware, Python utilities and frameworks. I tend
to dislike IDEs as embedded doesn't lend itself well to that model.

I do Perl, every day. I'm not a fast coder, but sometimes work mates are impressed with my turn-around time. I tell them it's due to use of good tools, and I ALWAYS use that as opportunity to talk about BBEdit. ;-)

Reply all
Reply to author
Forward
0 new messages