Binary editor written in Go

Overview

bed

CI Status Go Report Card MIT License release pkg.go.dev

Binary editor written in Go

Screenshot

bed command screenshot

Why?

Why not? Programming is so fun!

I learned so much while creating this editor; handling of file pointers, what the saying details should depend on abstractions mean, how to mock file system for tests in Go language, how to solve deadlock or race conditions between goroutines and many other things.

After all, creating by yourself is the best way to learn how it works.

Okay, but why?

I actually want a binary editor with Vim-like user interface, which runs in terminals, portable, fast and with window splitting feature. I think I started coding for what I want before doing research on existing editors.

Installation

Homebrew

brew install itchyny/tap/bed

Build from source

go get github.com/itchyny/bed/cmd/bed

Features

  • Basic editing: inserting, replacing, deleting bytes
  • Support for large files
  • Window splitting
  • Partial writing
  • Text searching

Note that this software is still in its early stage of development. Please refer to #1 for roadmap.

Commands and keyboard shortcuts

This binary editor is influenced by the Vim editor. So if you have experience with Vim, you will notice most of basic operations of Vim are supported with this binary editor too.

  • File operations
    • :edit, :enew, :new, :vnew, :only
  • Quit and save
    • :quit, :qall, :write, :wq, :xit, :xall, :cquit
  • Window operations
    • :wincmd [nolhkjtbpKJHL], [nolhkjtbpKJHL]
  • Mode operations
    • i, I, a, A, R, , v
  • Undo and redo
    • :undo, u, :redo,
  • Moving cursor
    • :{count}, :{count}goto, :{count}%
  • Searching
    • /, ?, n, N, (to abort)

Bug Tracker

Report bug at Issues・itchyny/bed - GitHub.

Author

itchyny (https://github.com/itchyny)

License

This software is released under the MIT License, see LICENSE.

Issues
  • Added q! - command

    Added q! - command

    Hey,

    I have added the q! command, which discards all changes and quits the editor. Furthermore, if someone now tries to quit with the q command while changes have not been saved, it will fail and display an error message.

    Since this is my first time contributing to a go open source project, I would appreciate any feedback!

    Best regards, Dario! :)

    opened by Zarathustra2 6
  • Place a cursor at the smaller position after copying in visual mode

    Place a cursor at the smaller position after copying in visual mode

    If you have intentionally decided to adopt the current behavior, I'm willing to withdraw this PR.

    Note that the smaller position in the title refers to the smaller of start and end in line 810 of window/window.go.

    opened by elpinal 4
  • How does it work?

    How does it work?

    Please include a usage section in your readme, I like the idea of a console editor written in Go, I was recently looking for a good one and ended up writing my own. The only problem is that I have no idea how to use your editor. Instead of the "why" section I would rather like to have a concise manual with all keyboard shortcuts and possible command line parameters explained. Also I was trying to call bed with -h --help and /? which I think should all really print the same kind of help that should be in the readme. Thanks very much for sharing this editor!

    opened by gonutz 3
  • Move cursor in previous/next line

    Move cursor in previous/next line

    Thanks for the great work!

    I didn't see this on the roadmap, so it would be a nice feature if the cursor automatically moves in the previous/next line if the cursor in on the left or right side.

    E.g. Cursor at 0/b + press /L should jump to 0c/0 and not stuck at the same place.

    bed_arrow

    opened by fxha 3
  • Improve replace mode

    Improve replace mode

    1. Now the replace-byte command (r) only replace 1 byte.
    2. r command does nothing for empty windows.
    3. In replace mode backspace does not delete original text.

    But there are some issues:

    1. Panic (integer divide by zero) occurs when interleaved with x command.
    2. It is not trivial to determine what should happen when moving a cursor by arrow keys in replace mode.

    I guess Buffer.Replace should increment the length when offset for replacing equals length so that in buffer/buffer_test.go, TestBufferReplace's last 3 test cases should set len to 17.

    https://github.com/itchyny/bed/blob/517e02f6511bbed890f2df35636c6f88bebd21d0/buffer/buffer_test.go#L400-L402

    Related to #12.

    opened by elpinal 3
  • Holding 'p' key pressed leads to an uncontrollable state

    Holding 'p' key pressed leads to an uncontrollable state

    First, copying something by y command in visual mode.

    Second, holding p key pressed to paste the copied text repeatedly.

    Then, the bed program hangs up before long.

    opened by elpinal 3
  • Quit after undo

    Quit after undo

    Minor bug

    Since #25 users cannot leave the editor with :q if they have unsaved changes.

    If I edit a file but undo it till the state I opened the file, I am still forced to quit with :q! even though there are no changes.

    I think this could be solved if for the file maybe a hash would be saved of the last saved state. But I am not sure if this is the best way to solve this minor problem.

    opened by Zarathustra2 2
  • Can't search beyond currently loaded chunk?

    Can't search beyond currently loaded chunk?

    When using the search (/) command I can't seem to get results for any strings that aren't already visible on the screen. If I scroll down to where a string becomes visible, then hitting 'n' will then jump to it, but if it's not on the screen, 'n' will do nothing. Is this correct?

    opened by moshee 2
  • Backspace in replace mode: Is it desired behavior?

    Backspace in replace mode: Is it desired behavior?

    As it is, in replace mode, backspace can delete bytes which exist before entering replace mode. It is clearly different from Vim. Moreover, it may be frustrating to partially undo replacing.

    opened by elpinal 2
  • Roadmap: known issues and coming new features

    Roadmap: known issues and coming new features

    Thank you for getting interested in my product.

    Notes:

    • This product is my hobby product. Please do not ask me when some features will be implemented. I will implement what I want when I need (mostly) on weekends.
    • Your advice for new features are welcome. I'm not familiar with reverse-engineering, I'm not an expert of some binary file format.
    • This project is open sourced. You can freely create a fork of the repository. I appreciate if you send me patches to improve features, fix some bugs and so on.

    Multi-platform distribution

    • [x] ~Testing on TravisCI~
      • [x] Test in GitHub Actions 8947cd1
    • [x] Homebrew rule
    • [x] Windows support
      • [x] Fix panic: send on closed channel on exit 316b04c25d846b4a0773831ffadec4eb9c89ef91
      • [x] Write fails with Access is denied.: disable overwrite on Windows for now fb381a71457c8abfe3c6cfe5fb5073849e782c12
      • [x] Make tests pass on Windows 1fdf7a533f501c5a71a564549ea7e3744236527c
      • [x] Test on AppVeyor e8df7d5cbe7b262f1abfcc580e932ac756cd6af9
    • [x] Distribution from GitHub Releases

    Small bugs

    • [x] Visual mode should accept count for key mappings 6ce206ce2850e8f274faa6c1ff4dab5e7fde4180
    • [ ] Cursor position should be taken into account on switching between windows
    • [ ] One key stroke is missing after process suspension on macOS (known issue of tcell)
    • [x] Replace (r) should exit replace mode at once 1087bf9a57f6329b74c2b920f4a6b9615c32f56b

    New features and improvements

    I will definitely fix or implement these features.

    • [x] Yank, cut and paste: 1817e545777392d4320f907a4a2c2535cf05d84d c39eb953a93815c53f334bd24ee7e40dce9ed209 260b641ad49768c0f6b20b09146454bf1a56fdae
    • [x] Delete bytes (x, X) should copy the deleted region 8c3f9620c0db3d21eb747a29707b8a49f706ec4f 5d278e2f40a17fe88b60f4c04fcfab1a79cb863e 3eded553410fe172fb27b13df7b81b8648fd0575
    • [x] Alternative buffer switching f4f4a52b37198da993fc85b9512a790f3be89a1f 9d4a72e85e90b35cb82a40b26b512e91fdd1927b c2e62b892580cf3efb4f3380221c85dce7d23128 14c60c0b8c01eecec4d76e5daacf394f61d273dd
    • [x] Search by bytes 2e929ee63244a59f013bbae136153fbda03a9711
    • [x] Search in asynchronous loop ccab6b84bab0b353bb903a1b8aa036a21450e1f7.
    • [ ] Bitwise editing
    • [ ] Marks
    • [ ] Registers
    • [ ] Aborting write with c-c
    • [x] Command flags (--version, --help, etc.) feb31e1124ede7a423fdf2f6720ec27a8047e9ee
    • [ ] Command line history
    • [ ] Mouse support
    • [ ] Execute external command
    • [x] Vendor tcell with dep e47daf1dd8576a5fe4048ce0a5df789ea06032a2
      • Migrated to Go modules d3d4eb0b4bc7e10c524624293b19e3f445ba1d01

    More commands

    • [x] zt, zz, zb de8947caa91a978b6895d054ac3ebb7985974d3d 27f14bfc22009ef3f6cb75281b9b637ddda9073d 0841ff7bc946681aebe79a865d3da9901d6415a4 c1cff0d4b47bec24e691d7f0d8183b6bd7cd29c9 342e972c19dd2dc07c98718d13e6845a36c7b9ee cb213edba738ec28dd89cfabd0ed2276ae061bdb
    • [x] :enew command e0dcb7fdd1aa3c3b4fa0ccedb7c40173d30281a1
    • [ ] :buffer/:ls command
    • [ ] :below command
    • [ ] :split/:vsplit commands
    • [ ] :topleft/botright/... commands
    • [x] :only command 9124fcb75105db83ef835b2a6c02954f58754480
    • [ ] :new/:vnew should accept count to open with the specific height/width

    More features

    Please do not expect me to implement these features, but I'm interested in. I need some feedbacks.

    • [ ] Help buffer (:help)
      • Embed markdown documents?
    • [ ] Diff (:diffthis/:diffoff)
    • [ ] File format inspector
      • Using debug/elf package?
      • It'll be tough to implement many kinds of binary file formats. But I think I have to support for executables at least. There are already many soft-wares so needs investigation.
      • I'm also interested in image formats.
    • [ ] Support multiple text encodings
      • bed is a binary editor. Maybe supporting for analyzer of executables has higher priority than text encodings.
    • [ ] Configuration
      • I think this product should provide the good defaults. I'm not sure which parts users may want to configure. Mappings, displayed formats, event hooks ...
    • [ ] Plugin
      • I can't imagine what kind of plugin is required for binary editors. I need some investigation of other editors.
      • Also, I don't want to create a new scripting language. gRPC support?
    • [ ] Tabs
      • I like the tab behavior of Vim. But I hear that many people like displaying buffers in tabs.
    • [ ] Session restoration
    • [ ] Macro and repeating
    • [ ] GUI frontend or web-based UI
    • [ ] Stdin support
    opened by itchyny 2
  • Extend some commands of normal mode to visual mode

    Extend some commands of normal mode to visual mode

    The following commands are added to visual mode:

    z<Enter>
    zz
    z.
    zb
    z-
    H
    M
    L
    /
    ?
    n
    N
    

    Explanation

    The first commit

    The former of the two commits is just refactoring. Since normal mode and visual mode share many commands, it is preferred to make the common commands explicit.

    The second commit

    The latter commit is what this Pull Request wants to do. It enables 12 normal commands also in visual mode.

    editor/editor.go is modified for the editor to get back to visual mode after a search is done which is in turn on visual mode.

    opened by elpinal 1
Owner
itchyny
Professional of jq.
itchyny
Source code editor written in Go using go-gtk bindings. It aims to handle navigation effectively among large number of files.

tabby Source code editor written in Go using go-gtk bindings. It aims to handle navigation effectively among large number of files. screenshot: depend

Mikhail Trushnikov 49 Dec 30, 2021
A graphical text editor

A A is a text editor inspired by the Sam and Acme text editors for the Plan 9 operating system. binary Latest Binaries https://github.com/as/a/release

null 309 Aug 6, 2022
A Programmer's Text Editor

The de Editor de is a programmer's editor. (Where that programmer happens to be driusan.) It's kind of like a bastard child of vim and Plan 9's acme e

Dave MacFarlane 399 Jul 27, 2022
A very religious text editor

--== Godit - a very religious text editor ==-- Screenshots: * https://nosmileface.dev/images/godit-linux1.png * https://nosmileface.dev/images/god

null 541 Jul 26, 2022
A modern and intuitive terminal-based text editor

micro is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the capabilities of modern terminals.

Zachary Yedidia 19.9k Aug 6, 2022
An Enhanced Go Experience For The Atom Editor

go-plus An Improved Go Experience For The Atom Editor Github: https://github.com/joefitzgerald/go-plus Atom: https://atom.io/packages/go-plus Overview

Joe Fitzgerald 1.5k Jul 14, 2022
Go version of Plan9 Acme Editor

Overview Go port of Rob Pike's Acme editor. Derived from ProjectSerenity but now increasingly divergent. ProjectSerenity was itself a transliteration

Robert Kroeger 325 Aug 6, 2022
WYSIWYG theme editor for Fyne

fyne-theme-generator WYSIWYG theme editor for Fyne Installation go get github.com/lusingander/fyne-theme-generator Usage You can change each parameter

Kyosuke Fujimoto 76 Aug 4, 2022
MdEdit is a Vi-like markdown editor built using Gio

MdEdit MdEdit is a Vi-like markdown editor built using Gio. It is extremely early stage software. The Vi editor lacks most functionality and might be

Steve Russo 3 Jun 29, 2022
Mini is a small text editor, inspred by antirez's kilo editor.

mini Mini is a small text editor, inspred by antirez's kilo editor. It aims to Keep it simple, stupid.

Ken Hibino 77 Aug 11, 2022
NERV Editor - A simple but peculiar text editor

nerved a simple but peculiar text editor introduction nerved is a text editor bu

kiasaki 5 Apr 12, 2022
sops is an editor of encrypted files that supports YAML, JSON, ENV, INI and BINARY formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP

sops is an editor of encrypted files that supports YAML, JSON, ENV, INI and BINARY formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP. (demo)

Mozilla 10.4k Aug 7, 2022
searchHIBP is a golang tool that implements binary search over a hash ordered binary file.

searchHIBP is a golang tool that implements binary search over a hash ordered binary file.

fblz 0 Nov 9, 2021
Source code editor written in Go using go-gtk bindings. It aims to handle navigation effectively among large number of files.

tabby Source code editor written in Go using go-gtk bindings. It aims to handle navigation effectively among large number of files. screenshot: depend

Mikhail Trushnikov 49 Dec 30, 2021
A modern UNIX ed (line editor) clone written in Go

ed (the awesome UNIX line editor) ed is a clone of the UNIX command-line tool by the same name ed a line editor that was nortorious for being and most

James Mills 45 May 29, 2021
tson is JSON viewer and editor written in Go

tson tson is JSON viewer and editor written in Go. This tool displays JSON as a tree and you can search and edit key or values. Support OS Mac Linux I

skanehira 129 Aug 8, 2022
a simple and lightweight terminal text editor written in Go

Simple Text editor written in Golang build go build main.go

buzz 3 Oct 4, 2021
Basic CLI save editor for Medieival Dynasty written in Go.

Medieival-Dynasty-save-editor Basic CLI save editor for Medieival Dynasty written in Go. Windows binaries Usage Backup your saves first. Made for GOG

null 0 Apr 12, 2022
elf binary parsing utility written in Go.

What is it ? go-readelf is a small elf binary parser currently capable of printing relocation entries, elf header, sections and Symbols. It utilizes G

null 58 Aug 7, 2022
Elf binary infector written in Golang

Elf binary infector written in Golang. It can be used for infecting executables of type ET_DYN and ET_EXEC with a payload of your creation. Utilizing the classic elf text segment padding algorithm by Silvio Cesar, your payload (parasite) will run before native functionality of the binary effectively backooring the binary.

null 150 Jul 27, 2022
A fully Go userland with Linux bootloaders! u-root can create a one-binary root file system (initramfs) containing a busybox-like set of tools written in Go.

u-root Description u-root embodies four different projects. Go versions of many standard Linux tools, such as ls, cp, or shutdown. See cmds/core for m

null 2k Aug 11, 2022
Pure Go line editor with history, inspired by linenoise

Liner Liner is a command line editor with history. It was inspired by linenoise; everything Unix-like is a VT100 (or is trying very hard to be). If yo

Peter Harris 910 Jul 28, 2022
A graphical text editor

A A is a text editor inspired by the Sam and Acme text editors for the Plan 9 operating system. binary Latest Binaries https://github.com/as/a/release

null 309 Aug 6, 2022
A Programmer's Text Editor

The de Editor de is a programmer's editor. (Where that programmer happens to be driusan.) It's kind of like a bastard child of vim and Plan 9's acme e

Dave MacFarlane 399 Jul 27, 2022
A very religious text editor

--== Godit - a very religious text editor ==-- Screenshots: * https://nosmileface.dev/images/godit-linux1.png * https://nosmileface.dev/images/god

null 541 Jul 26, 2022
A modern and intuitive terminal-based text editor

micro is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the capabilities of modern terminals.

Zachary Yedidia 19.9k Aug 6, 2022
An Enhanced Go Experience For The Atom Editor

go-plus An Improved Go Experience For The Atom Editor Github: https://github.com/joefitzgerald/go-plus Atom: https://atom.io/packages/go-plus Overview

Joe Fitzgerald 1.5k Jul 14, 2022
A modern and intuitive terminal-based text editor

micro is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the capabilities of modern terminals

Zachary Yedidia 19.9k Aug 9, 2022
Go version of Plan9 Acme Editor

Overview Go port of Rob Pike's Acme editor. Derived from ProjectSerenity but now increasingly divergent. ProjectSerenity was itself a transliteration

Robert Kroeger 325 Aug 6, 2022