Linux Learning Summary (15)-9 tips for improving Vim and Shell efficiency

Source: Internet
Author: User

When was the last time you used the CAPSLOCK key? It's been a long time, right? Oh, me too, it has been forgotten, it wasted a golden position on the keyboard. Let's re-map it to the Control key to play its part! This tells you how to do it on different operating systems.

Now you can keep the standard key gesture and tap the button to the a left crtl .

2. Use Ctrl-r to search and automatically redo history commands

Many people know that you can use the arrow keys to invoke the previous history command, but relatively few people know that a call can be used ctrl-r to quickly complete a history command.


Once the corresponding command is found, it can be executed by a carriage return, or the command is modified before execution, which makes it easy to get into a habit, especially after you re-map the CAPSLOCK key.

3. Using the OS X system ITerm

ITerm is not an efficient tool that has to be used, but it can definitely improve efficiency. It has the following characteristics:

  • Screen segmentation
  • Select that copy
  • Cut history
  • Full Screen Toggle
  • System Hotkey
  • Exposé All Tabs
  • Save current snapshot

I don't know who's going to change the iTerm. Come on.

4. Use Zsh as a Shell

Most people will be as Zsh as I used to be, and after seeing the virtues of a person, most people will be raving about it and never want to bash again. It has the following characteristics:

  • Catalog Completion:ve/pl/re --> vendor/plugins/redmine
  • Environment variable Expansion:$PATH --> /your/full/path
  • Smart FIX: /pbulic/html change/public/html
  • Spelling corrections
  • Command history sharing
  • Line Edit Highlight Mode
  • Perfectly compatible with most Bash configurations
  • When running/bin/sh, you can compare bash
  • Supports VIM mode
  • OHMYZSH Support

The last one is decisive, Ohmyzsh contains a number of plugins (including rails, git, OS X, Brew, etc.), with more than 80 terminal themes and Automatic Updates. Ohmyzsh through these to make the shell use very cool. Please see this for more details.

5. Re-mapping Vim's ESCAPE key

VIM has multiple modes and is not a big problem, but it can feel bad when switching between modes. The ESC key is a bit far away, which is too much trouble. When I face the new vim environment, the first thing I do is to add the following mappings

6. Re-mapping Vim's Leader key

If you are not familiar with the leader key, and do not know what it can do for you, then you begin to understand it. It is essentially the activation key for your shortcut key, and you can customize which key to use as your leader key. So, you can:

This allows you to press the leader key combined with the uppercase ' J ' after visualizing the entire segment and joining the line.

I personally use ', ' key as my leader key, so I can use ', ' to activate all my shortcuts and then exit the insert mode by ' JJ '. You can .vimrc map like this in the:

7. Use VI mode in the Shell

Whether it's zsh or bash, you'll want to use the same muscle memory as much as possible, if you're a vim user, which means you should switch your shell from Emacs mode (default) to VI mode

This means that you can edit your shell command line in a vim way:

    • b   return previous word
    • DD   Delete entire row
    • 0, $ move to the end of the line
    • < Span style= "Font-family:courier New; font-size:18px; Color: #ff0000; Background-color:rgb (255,255,255) "> ... Wait a minute.

You can do this by adding the following line of code to .zshrc or to .bashrc the file:

You can also map your escape key like Vim:

1 bindkey -M viins ‘jj’ vi-cmd-mode

Another benefit is that you can j、k go through the natural browsing history. You can also .zshrc add functionality in your files by following the code ctrl-r .

8. Add Tmux to Workflow

Tmux is a terminal multiplexer that allows you to connect and manage multiple server-side sessions. tmuxyou can start and connect conversations in, and you can disconnect and then connect again at different times and locations.

You may be familiar with similar solutions, GNU screen, but compared to screen, tmux there are the following advantages:

  • Screen is a big and heavy project, and there are many problems in its coding.
  • Tmux is a lightweight project with a modern, efficient code base
  • Tmux is a complete client server project and screen emulation software
  • Tmux support for Vim and Emacs keyboard layouts
  • Tmux supports automatic renaming of windows at run time
  • Tmux can be easily scripted through the shell
  • The tmux comes with a vertical split screen, and screen is fixed dead

If you do not use the terminal multiplexing function, you can also try Tmux, you will benefit. [UPDATE: This has TUMX's most complete Enlightenment book. ]

9. Synchronizing the working Environment

Well, in your MBP you can experience the cool shell and vim, but once you SSH into your Linux you will feel completely different, which is annoying. Fortunately, this problem can be handled synchronously.

    1. Create a repository for your profile on Git, for example: Bash, Zsh, Vim, and so on. Remember to stay updated.
    2. Clone a copy (config file) to the directory of the corresponding system on each system you use.
    3. There are comments that can be synced with Dropbox, which seems great, but I'm not sure how it works on a Linux server with Headless (Headless means no display, keyboard, mouse, etc.).

Linux Learning Summary (15)-9 tips for improving Vim and Shell efficiency

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.