NERDBUDE

[ code. keyboards. terminals. cyber. ]

[HOWTO] [WHOAMI] [PODCAST] [FRANKENSWITCHES] [GERMAN]

VIM VI



INTEGRATION

The article title could be confusing it is not about "Vim vi" but about the 6th part of the NERDBUDE Vim series. This part will not necessarily be exciting for everyone. On my systems I try to do all tasks in the terminal. This saves resources, is faster and can be done perfectly with the keyboard (the weakness should be known). Vim itself offers the possibility of a GUI but we exclude that here. If now everything should be done in the terminal I'll have a look how far Vim can be integrated into the daily workflow. Now I use NixOS (high performance) with XMonad (small, fast and completely keyboard controllable) and as interface several mechanical keyboards. So everything is designed to move my hands as little as possible. Vim can be a valuable intersection to operate tools without having to leave the editor or to bend or use Vim so to save me intermediate steps and memory space.

SSH

In the course of a small project (a cyber walkman podcast player - coming soon.) or even just editing files on nem Raspberry Pi there are two possibilities.
Edit the files via SSH on the Raspi. Disadvantage: Vim must be configured first and that costs time. Option 2: Download the file, edit it and put it back on the Raspi. Much better but still too many steps.

Now the dear @cubadonis the last few days, in response to a tweet regarding the Vim series here, answered a possibility that, the intermediate steps significantly steamed.
Via "scp" (secure copy) files can be transferred via SSH to or from servers to which access is available.
So why not the instruction Vim should load a file via SSH from a remote instance directly into a buffer and when saving it also write it directly back to the server via SSH.
Sounds incredibly complicated, but it's really simple. The commands for this look like this:

TERMINAL
vim scp://user@server:port//path/to/remotefile


This will open Vim and in Vim directly "scp" incl. password request for the SSH Connect. If you have entered the password, you see the file in Vim and can edit it. When saving the file with ":w" the password will be asked again and saved remotely to the server. Vim-Magic at its best. Thanks Cuba - didn't know this yet - will use it daily now.

LINUX TERMINAL

When writing scripts or programs, of course they want to be tested regularly. Now it is quite simple in my case under XMonad briefly initialize a new terminal (Mod + Enter). But there is also the possibility to start a new terminal directly in Vim and to work there with the known commands. This can be done in two ways:

VIM / NORMAL MODE
:! <command>
:term <command> (ab Vim 8.0)


The first option ":! <command>" tells Vim with the command ":!" that a terminal command follows and should be executed. When the command is executed, Vim itself is pushed into the background and only when the command is finished, Vim appears in the foreground again. The mMn. better variant is ":term". This Vim command is available from ver8.0 of Vim. The advantage is obvious here. Vim is not pushed into the background, but the terminal is initialized as a split window in Vim. With "CTRL + W" you can then switch normally between editor and terminal window. This allows parallel working on the file and testing in the terminal. So quasi the terminal in Vim in the terminal.

GIT

Also often in use: git. The good old version control on which also GitHub and Gitlab are based. Vim can already handle "git" in simple principles. As in the section above, we can open a terminal in Vim and work there via "git" terminal commands. This way, Vim always stays nicely open and doesn't need to be exited for that. However, a little bit more integration into Vim is brought by a plugin called "Vim-Fugitive". Vim-Fugitive allows the use of git commands in Vim itself. The plugin can be conveniently used via Pathogen (PART IV). If "Vim-Fugitive" is installed, git can be used directly in Vim.

VIM / NORMAL MODE
:Git
:G


This will enable the functionality of the plugin, followed by the specific git command you want:

VIM / NORMAL MODE
:G add
:G commit
:G diff
:G log 
:G blame
:G status


... and so on. So the full git feature set in Vim.
.

TWITTER

Yep right. Twitter is important and is part of daily life and yes Twitter exists for Vim.
. Here unfortunately not integrated from the start in Vim but fortunately usable via plugin. The plugin is available here: twitvim. To use TwitVim after the installation you only need the following command (and I write it here because I have to search forever every time :) ):

VIM / NORMAL MODE
:SetLoginTwitter


Here you are then generated a ShortURL to which you go and you only have to enter the Auth number in Vim and you can read Twitter comfortably in Vim but on tweet, search, etc.. TwitVim is operated by commands in NORMAL mode:

:PosttoTwitter
:FriendsTwitter
:RepliesTwitter
:UserTwitter
:RefreshTwitter


Actually, the commands are quite self-explanatory, but here is the explanation for completeness:
. :PosttoTwitter - After confirming the command, you will be prompted with "tweet:" to enter your tweet text.
:FriendsTwitter - Show all the tweets of the people you follow
. :RepliesTwitter - Shows your replies.
:UserTwitter - Shows the tweets of a specific user
. :RefreshTwitter - Refreshes the timeline you are looking at.

This is how the whole thing looks then:



Plugins like NERDTree and VimWiki I already described here: PART 4
. Again, VIM AWESOME, I think no matter what you're looking for, you'll find it here.

FAZIT

. This little 6 part series should be enough to get you started using Vim productively. The basics like navigation, copy & paste, markups but also a step deeper in terms of plugins and modes should be understandable. Vim is a rabbit hole with many forks. No matter what you are thinking of doing with Vim, it will be possible and with the help of plugins it is usually relatively easy to integrate into Vim. This won't be the last NERDBUDE post about Vim for sure (I'm currently building the Unit-2 theme for Vim - it will all show up here, of course). If I find other stuff about Vim, I'll put it here, too, of course. But now have fun with Vim and the "wonderful" learning curve of Vim.



//EOF