I have updated edit-slack.vim
Tags: vim, slack, go
Published: 2021-04-03 14:50:08

---
title: I have updated edit-slack.vim
published: true
description: update vim plugin for slack
tags: vim, slack, golang
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i6d06leiiivchyasa08n.gif
---

https://github.com/yaasita/edit-slack.vim

I have updated my slack plugin because it was not working.

# What is this

This is a plugin to post to slack from vim.
You can send a message using only vim.
![demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v6pwy9o53s05y31l0vnf.gif)

This is a post from vim to slack via a binary written in golang
![How it works](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a5uyawdb4yrjmwdkkdbk.png)
(c) [gopher stickers](https://github.com/tenntenn/gopher-stickers)

The display will invoke the command if the buffer name starts with "slack://".

```
autocmd BufReadCmd slack://* call edit_slack#Open(expand("<amatch>"))
```

The post gets the part written below "=== Message ===" in vimscript.
vim passes it in the standard input of the command.

![post data](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s0tw083dhhcske8sxx76.png)

Run the following script when you write
```
autocmd BufWriteCmd slack://* call edit_slack#Write(expand("<amatch>"))
```

Call system() in the function

```
call system(command, postdata)
```

Update details are as follows.

# Upgrade golang

Updated golang version to 1.15.
I've also added the use of Module and [slack-go](https://github.com/slack-go/slack).

# Support for slack's new API

* [Support new token](https://api.slack.com/legacy/custom-integrations/legacy-tokens)
YouTube：{%youtube z9PD7-UXSbA%}

* Change to use [ConversationsAPI](https://api.slack.com/methods#conversations)

All channels can be opened with the following rules

```
# list
slack://ch

# channel
slack://ch/<channel name>
```


# Threaded support

```
# Threaded uri
slack://ch/<channel name>/<timestamp>
```

Added the command `:EditSlackOpenReplies` to open threads.
![open thread](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxsuozrvr9e8g29zgdtn.gif)

You need to get the timestamp for each statement to open the thread. I used to show it in the message list, but it got too cluttered and hard to read, so I hid it with the [conceal function](http://vimdoc.sourceforge.net/htmldoc/syntax.html#conceal).
If you set syntax on, it will be hidden.

![syntax on](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gozqa2m3hh33pkbzssdq.gif)

If you change `[]` to `[x]`, you can also post to the channel.
However, there is a bug in slack that causes the name and icon to belong to the application.

![broadcast](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dpap0zm6kq2xn5j743hk.gif)

# Joining and leaving the channel

`:EditSlackJoin` / `:EditSlackLeave`

![join and leave](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ez00iu6m2b7gz0h9djll.gif)

# Uploading and downloading files

Added support for downloading and uploading files.


```
:EditSlackDownloadFile /path/to/savefile
:EditSlackUploadFile /path/to/uploadfile
```

![upload1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kvanxx4w2qxrd1ctvgd0.gif)
![download1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xef307de96wm5gdmtkp.gif)

# Search command

Added a search function.

```
:EditSlackSearch search_word
```
![search](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2c7tvc40zubvb5wyqw0.gif)


# Other functions

It may support reaction functions in the future.