Build IDE with Tmux and Vim

Source: Internet
Author: User
Tags dotfiles

Build IDE with Tmux and Vim

When I visited an office, one of my friends found that their employees were using tmux and vim tools to develop Ruby projects. He wondered why people would rather give up the convenience of mouse input and choose to use the console version of vim for work.

In the end, I found that this is a very good way to work. At first, I used the console vim to force me to correctly learn the vim shortcut key (motion commands ). Combined with the blind play, vim provides powerful commands to jump to multiple files and multiple code lines, which is undoubtedly more efficient than using the mouse.

I used to tile terminal tools with the code editor. In web development, a console is usually used to input ad-hoc commands, operate databases on the console, and view logs on the console. Some of my projects also use test tools to perform automated tests on revised files, so I also want to see the status of these tests.

Vim provides many plug-ins to integrate the above functions, but I prefer the combination of vim and tmux. This is a visualized operation tool.

Using the command line tool in this way, we can efficiently create a lightweight and customizable IDE. I also found that it is useful to enter Unix commands in multiple console panes (pane) of tmux, this method can easily combine commands to provide complex scripting operations without the need for bloated IDE tools.

The difference between this method and traditional IDE is that the interface provided by IDE is very compatible with my current work, and it is limited by the command line tool installed by me and the scripting language. I can create the tmux pane (pane) and vim split windows as needed, instead of developing any templates. Although Eclipse and Xocde provide some task-centric interfaces, I still think these are some of the reasons. Especially in Xcode, the shortcut keys provided by it are like they are only supplemented later. I still have to keep using the mouse for operations.

Quick Switching between tasks is another advantage. I am a freelancer and usually need to switch between 3 and 4 projects in a day. After using tmux, I can disconnect (detach) A session and then switch back later to continue, which enables me to focus on the current job. I think this is a great advantage of the console vim tool compared to GUI vim or opening a bunch of console work at the same time, because Eclipse and Xcode always try to save the interface status when they close the project (however, the latest version of Xcode always closes the split window that I open when closing the project ).

 

Why use the hjkl key?

This operation may seem awkward, but if you are proficient in playing blindly, vim and tmux (configured as vim key style) it is easy to keep your fingers away from the mouse and operate only in the home row of the primary key area of the keyboard. (Note: home row refers to the "A, S, D, F, J, K, L, and;" buttons on the keyboard .)

This is exactly the secret of the hjkl key: for those with high precision in blind play. For those who are not used to these buttons, try them for several days. Focus on the correctness of typing and make full use of your 10 fingers.

The use of the hjkl key reminds me of how to persuade beginners to use the wasd key instead of the direction key. At first, wasd was not intuitive, but it made it easier to use both the keyboard and mouse. The advantages of this method are obvious.

 

Configuration prompt

I am in ~ /. Configure the following in the tmux. conf file:

  1. set-window-option -g mode-keys vi
  2. bind h select-pane -L
  3. bind j select-pane -D
  4. bind k select-pane -U
  5. bind l select-pane -R

This allows me to use vim shortcut keys in tmux.

If You are trying to grasp the shortcut Keys of vim, disable the Arrow Keys in vim editing mode. For details, refer to Vim: Making those Arrow Keys Work With You.

If you are a newbie to vim, it is worth mentioning that vim supports ctags. In addition, the TagHighlight plug-in can dynamically display multiple tags (tags) in the current file editing cache in pane, which is similar to the IDE function.

 

Dotfiles

Can your IDE configuration file be synchronized across multiple computers?

I have a private git library named dotfiles for storing vim and ctags configurations and plug-ins. I wrote an installation script to automatically create a symbolic link to the configuration file for the local dotfiles library. Once I use a new computer, I first check out the git library. Later, when I open a project and edit it, vim and tmux are configured according to the method I used to use.

 

Copy and paste

I often need to use the copy and paste commands of tmux to copy the console output to vim. The shortcut keys vary greatly based on different configurations of tmux. Therefore, it is worth reading the tmux manual and understanding its working principles. By default, "ctrl-B [" is used to Enter the copy mode. Use space to start Content Selection, Enter to copy the content, and then press ctrl-B] to paste it.

 

Shortcut Key

If you want to use vim efficiently, you must consider whether there are related shortcut keys for operations that depend heavily on the keyboard. For example, when I use it for the first time ~ When the shortcut key is used for case-insensitive conversion, I think "This is really funny, and I will never use it again ". Actually, I used this article three times.

I later found the tips for using shortcuts, because I noticed that some experienced vim users are trying to avoid using the insert mode as much as possible ). Therefore, you must take a look at the vim Help manual. Then you will find that there are so many good ways to improve your editing skills.

Tmux 1.8 released, a Linux terminal multiplexing

Tmux: terminal multiplexing

Simple tmux tutorial

Install and use Tmux in CentOS

Tmux details: click here
Tmux: click here

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.