使用 Vim 管理任务列表和访问 Reddit 和 Twitter
TODO

> 
> 在 2020 年用开源实现更高生产力的二十种方式的第十七篇文章中，了解在编辑器中处理待办列表以及获取社交信息。
> 
> 
> 


![](/data/attachment/album/202002/21/112633yf3mx8qlssltugzm.jpg)


去年，我在 19 天里给你介绍了 19 个新（对你而言）的生产力工具。今年，我换了一种方式：使用你在使用或者还没使用的工具，构建一个使你可以在新一年更加高效的环境。


### 用 Vim 做（几乎）所有事情，第 2 部分


在[昨天的文章](/article-11908-1.html)中，你开始用 Vim 检查邮件和日历。今天，你可以做的更多。首先，你会在 Vim 编辑器中跟踪任务，然后获取社交信息。


#### 使用 todo.txt-vim 在 Vim 中跟踪待办任务


![to-dos and Twitter with Vim](/data/attachment/album/202002/21/112830trfhamwjmzkahref.png "to-dos and Twitter with Vim")


使用 Vim 编辑一个文本待办事件是一件自然的事，而 [todo.txt-vim](https://github.com/freitass/todo.txt-vim) 包使其更加简单。首先安装 todo.txt-vim 包：



```
git clone https://github.com/freitass/todo.txt-vim ~/.vim/bundle/todo.txt-vim
vim ~/path/to/your/todo.txt
```

todo.txt-vim 自动识别以 `todo.txt` 和 `done.txt` 结尾的文件作为 [todo.txt](http://todotxt.org) 文件。它添加特定于 todo.txt 格式的键绑定。你可以使用 `\x` 标记“已完成”的内容，使用 `\d` 将其设置为当前日期，然后使用 `\a`、`\b` 和 `\c` 更改优先级。你可以提升（`\k`）或降低（`\j`）优先级，并根据项目（`\s+`）、上下文（`\s@`）或日期（`\sd`）排序（`\s`）。完成后，你可以和平常一样关闭和保存文件。


todo.txt-vim 包是我几天前写的 [todo.sh 程序](https://opensource.com/article/20/1/open-source-to-do-list)的一个很好的补充，使用 [todo edit](https://github.com/todotxt/todo.txt-cli/wiki/Todo.sh-Add-on-Directory#edit-open-in-text-editor) 加载项，它可以增强的你待办事项列表跟踪。


#### 使用 vim-reddit 读取 Reddit


![Reddit in Vim](/data/attachment/album/202002/21/112840gdiy499zxpx9xixt.png "Reddit in Vim")


Vim 还有一个不错的用于 [Reddit](https://reddit.com) 的加载项，叫 [vim-reddit](https://github.com/DougBeney/vim-reddit)。它不如 [Tuir](https://opensource.com/article/20/1/open-source-reddit-client) 好，但是用于快速查看最新的文章，它还是不错的。首先安装捆绑包：



```
git clone https://github.com/DougBeney/vim-reddit.git ~/.vim/bundle/vim-reddit
vim
```

现在输入 `:Reddit` 将加载 Reddit 首页。你可以使用 `:Reddit name` 加载特定子板。打开文章列表后，使用箭头键导航或使用鼠标滚动。按 `o` 将在 Vim 中打开文章（除非它多媒体文章，它会打开浏览器），然后按 `c` 打开评论。如果要直接转到页面，请按 `O` 而不是 `o`。只需按 `u` 就能返回。当你 Reddit 看完后，输入 `:bd` 就行。vim-reddit 唯一的缺点是无法登录或发布新文章和评论。话又说回来，有时这是一件好事。


#### 使用 twitvim 在 Vim 中发推


![Twitter in Vim](/data/attachment/album/202002/21/112903gccw8ibkcs7a75cc.png "Twitter in Vim")


最后，我们有 [twitvim](https://github.com/twitvim/twitvim)，这是一个于阅读和发布 Twitter 的 Vim 软件包。它需要更多设置。首先从 GitHub 安装 twitvim：



```
git clone https://github.com/twitvim/twitvim.git ~/.vim/bundle/twitvim
```

现在你需要编辑 `.vimrc` 文件并设置一些选项。它帮助插件知道使用哪些库与 Twitter 交互。运行 `vim --version` 并查看哪些语言的前面有 `+` 就代表你的 Vim 支持它。


![Enabled and Disabled things in vim](/data/attachment/album/202002/21/112912bsvpze7aifida7py.png "Enabled and Disabled things in vim")


因为我的是 `+perl -python +python3`，所以我知道我可以启用 Perl 和 Python 3 但不是 Python 2 （python）。



```
" TwitVim Settings
let twitvim_enable_perl = 1
" let twitvim_enable_python = 1
let twitvim_enable_python3 = 1
```

现在，你可以通过运行 `:SetLoginTwitter` 启动浏览器窗口，它会打开一个浏览器窗口要求你授权 VimTwit 访问你的帐户。在 Vim 中输入提供的 PIN 后就可以了。


Twitvim 的命令不像其他包中一样简单。要加载好友和关注者的时间线，请输入 `:FriendsTwitter`。要列出提及你的和回复，请使用 `:MentionsTwitter`。发布新推文是 `:PosttoTwitter <Your message>`。你可以滚动列表并输入 `\r` 回复特定推文，你可以用 `\d` 直接给某人发消息。


就是这些了。你现在可以在 Vim 中做（几乎）所有事了！




---


via: <https://opensource.com/article/20/1/vim-task-list-reddit-twitter>


作者：[Kevin Sonney](https://opensource.com/users/ksonney) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
Last year, I brought you 19 days of new (to you) productivity tools for 2019. This year, I'm taking a different approach: building an environment that will allow you to be more productive in the new year, using tools you may or may not already be using.

## Doing (almost) all the things with Vim, part 2

In [yesterday's article](https://opensource.com/article/20/1/send-email-and-check-your-calendar-vim), you started reading mail and checking your calendars with Vim. Today, you're going to do even more. First, you'll take care of your task tracking, and then you'll get social, directly in the Vim text editor.

### Track your to-do's in Vim with todo.txt-vim

![to-dos and Twitter with Vim to-dos and Twitter with Vim](https://opensource.com/sites/default/files/uploads/productivity_17-1.png)

Editing a text-based to-do file with Vim is a natural fit, and the [todo.txt-vim](https://github.com/freitass/todo.txt-vim) package makes it even easier. Start by installing the todo.txt-vim package:

```
git clone https://github.com/freitass/todo.txt-vim ~/.vim/bundle/todo.txt-vim
vim ~/path/to/your/todo.txt
```


Todo.txt-vim automatically recognizes files ending in todo.txt and done.txt as [todo.txt](http://todotxt.org) files. It adds key bindings specific to the todo.txt format. You can mark things "done" with **\x**, set them to the current date with **\d**, and change the priority with **\a**, **\b**, and **\c**. You can bump the priorities up (**\k**) or down (**\j**) and sort (**\s**) based on project (**\s+**), context (**\s@**), or date (**\sd**). And when you are finished, you can close and save the file like normal.

The todo.txt-vim package is a great addition to the [todo.sh program](https://opensource.com/article/20/1/open-source-to-do-list) I wrote about a few days ago, and with the [todo edit](https://github.com/todotxt/todo.txt-cli/wiki/Todo.sh-Add-on-Directory#edit-open-in-text-editor) add-on, it can really supercharge your to-do list tracking.

### Read Reddit in Vim with vim-reddit

![Reddit in Vim Reddit in Vim](https://opensource.com/sites/default/files/uploads/productivity_17-2.png)

Vim also has a nice add-on for [Reddit](https://reddit.com) called [vim-reddit](https://github.com/DougBeney/vim-reddit). It isn't as nice as [Tuir](https://opensource.com/article/20/1/open-source-reddit-client), but for a quick review of the latest posts, it works really well. Start by installing the bundle:

```
git clone https://github.com/DougBeney/vim-reddit.git ~/.vim/bundle/vim-reddit
vim
```


Now type **:Reddit** and the Reddit frontpage will load. You can load a specific subreddit with **:Reddit name**. Once the article list is onscreen, navigate with the arrow keys or scroll with the mouse. Pressing **o** will open the article in Vim (unless it is a media post, in which case it opens a browser), and pressing **c** brings up the comments. If you want to go right to the page, press **O** instead of **o**. Going back a screen is as easy as **u**. And when you are done with Reddit, type **:bd**. The only drawback is vim-reddit cannot log in or post new stories or comments. Then again, sometimes that is a good thing.

### Tweet from Vim with twitvim

![Twitter in Vim Twitter in Vim](https://opensource.com/sites/default/files/uploads/productivity_17-3.png)

And last, we have [twitvim](https://github.com/twitvim/twitvim), a Vim package for reading and posting to Twitter. This one takes a bit more to set up. Start by installing twitvim from GitHub:

`git clone https://github.com/twitvim/twitvim.git ~/.vim/bundle/twitvim`


Now you need to edit the **.vimrc** file and set some options. These help the plugin know which libraries it can use to talk to Twitter. Run **vim --version** and see what languages have a **+** next to them—those languages are supported by your copy of Vim.

![Enabled and Disabled things in vim Enabled and Disabled things in vim](https://opensource.com/sites/default/files/uploads/productivity_17-4.png)

Since mine says **+perl -python +python3**, I know I can enable Perl and Python 3, but not Python 2 (python).

```
" TwitVim Settings
let twitvim_enable_perl = 1
" let twitvim_enable_python = 1
let twitvim_enable_python3 = 1
```


Now you can start up Vim and log into Twitter by running **:SetLoginTwitter**, which launches a browser window asking you to authorize VimTwit as an application with access to your account. Once you enter


the supplied PIN into Vim, you're good to go.

Twitvim's commands are not as simple as in the other packages. To load up the timeline of your friends and followers, type in **:FriendsTwitter**. To list your mentions and replies, use **:MentionsTwitter**. Posting a new tweet is **:PosttoTwitter <Your message>**. You can scroll through the list and reply to a specific tweet by typing **\r**, and you can start a direct message with someone using **\d**.

And there you have it; you're doing (almost) all the things in Vim!

## 1 Comment