How to make tmux and vim into IDE in Linux system

  
                

In Linux, two tools, tmux and vim, can be used to develop projects. Many people prefer to use tmux and vim without keyboard and mouse to illustrate that these two tools are unique. This article will introduce the tmux and vim into an IDE in the Linux system.

Many people are accustomed to the terminal tool and code editor tiled together. Web development work usually requires a console for entering ad-hoc commands, a console operation database, and a console to view logs. At the same time, some of my projects use test tools to automate the testing of revised files, so I also hope to see the status of these tests at the same time.

vim provides a lot of plugins to integrate these features, but I prefer the vim/tmux combination. This is a visual operation tool.

Universal This way, using command line tools, we can efficiently build a lightweight, customizable IDE. I also found that the way to enter Unix commands in multiple console panes of tmux is very useful because it makes it easy to combine commands to provide complex scripting operations without the need for bloated IDE tool.

The difference between this usage and the traditional IDE is that the interface provided is very suitable for my current work, and it is only limited by the command line tools I installed and the scripting language. I can create tmux panes and vim split windows as needed, without developing any templates. Although Eclipse and Xocde provide some task-foruce interfaces, I still feel that this is a bit confusing. Especially Xcode, the shortcut keys it provides feel like it's added later, I still have to use the mouse to operate.

Supporting fast switching between tasks is another advantage. I am a freelancer and usually I need to switch between 3 or 4 projects a day. After using tmux, I can detach a session and then switch back to continue, which allows me to focus on the current work. I think this is a great advantage of the console vim tool compared to the GUI vim or a bunch of consoles at the same time, because Eclipse and Xcode always try to save the interface state when closing the project (but the latest version) Xcode seems to always close the split window I opened when closing the project.

Why use the hjkl key

This way of operation may seem awkward, but if you are skilled at blind typing, vim and tmux (configured as vim key style) can easily make fingers Keep away from the mouse and only keep it in the home row of the keyboard. (Translator's Note: home row refers to the keyboard on the "A, S, D, F, J, K, L,;" "These eight buttons.)

This is the hjkl key Secret: For those who have a high rate of blind hits. For those who are not used to using these buttons, you can try it for a few days. And focus on the correctness of typing, make the most of your ten fingers.

The use of the hjkl key reminds me of convincing game beginners to use the wasd key instead of the arrow keys. At first, wasd did not feel intuitive, but it made it easier to use both keyboard and mouse. The advantages are obvious when adapted to this mode of operation.

Configuration Tips

Do the following in the ~/.tmux.conf file:

set-window-option -g mode-keys vi

bind h select-pane -L

bind j select-pane -D

bind k select-pane -U

bind l select-pane -R

This is a shortcut that allows me to use vim in tmux.

If you are trying to master the shortcuts of vim, please turn off the arrow keys in vim's edit mode. For details, please refer to: Vim: Making those Arrow Keys Work With You.

If you are a newcomer to vim, it is worth mentioning that vim supports ctags. There is also a TagHighlight plugin that dynamically displays multiple tags in the current file editing cache in the pane, which is an IDE-like feature.

Dotfiles

Can your IDE profile be synchronized across multiple computers?

I have a private git library called dotfiles that is dedicated to storing vim and ctags configurations and plugins. I wrote an installation script to automatically create a symbolic link to the local dotfiles library. Once I use a new computer, the first thing I do is check out the git library. Then when I open the project for editing, vim and tmux are configured according to the way I am used to.

Copy and Paste

I often need to copy the output of the console to vim using the tmux copy and paste command. Based on the different configurations of tmux, the shortcut keys are very different, so it is worthwhile to read the tmux manual and understand how it works. The default is to use “ctrl-b [“ to enter the copy mode, use the space bar (space) to start content selection, enter (Enter) to copy, and then use ”ctrl-b]” to paste.

Shortcuts

If you want to use vim efficiently, you must think about the relevant shortcuts for heavy keyboard-dependent operations. For example, when I first used the ~ shortcut (for case conversion), I think & ldquo; this is really funny, I will definitely not use it again. Ha, actually I used it three times when I was writing this article.

The above is a tutorial on tmux and vim in the Linux system, because tmux and vim have a lot of shortcuts, so it can completely replace the role of the mouse.

Copyright © Windows knowledge All Rights Reserved