LoginSignup
1
0

More than 1 year has passed since last update.

GoのCLIでテキスト入力をVimとかでやりたかった件

Last updated at Posted at 2022-03-08

はじめに

CLIのTwitterクライアントとか作りたいなー って思った
なので、複数行のTweetをコマンドラインで入力するんだったら、Vimとか使いたいなーって思った

ググった

GoでVimを開いて編集内容をパースする方法
最高やん!

結果

kotaoue/go-eeditorを用意した

import (
	"fmt"

	"github.com/kotaoue/go-eeditor"
)

func main() {
	editor := eeditor.NewEditor()
	b, _ := editor.Open()
	fmt.Println(string(b))
}

みたいなコードで、Vimでテキスト編集した結果をbyteで受け取れる

起動時のパラメータ変更すれば、Emacsも使える

editor := eeditor.NewEditor(eeditor.Command("emacs"))
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0