


Linux Tips: Cancel automatic indentation when pasting in vim
Preface
vim is a powerful text editing tool that has gained great popularity on Linux.
When I was using vim on another server recently, I encountered a strange problem: when I copied and pasted a locally written script into a blank file on the server, automatic indentation occurred.
To use a simple example, the script I wrote locally is as follows:
aaa bbb ccc ddd
When I copied the above content and pasted it into a blank file on the server, what I got was:
aa bbb ccc ddd
Obviously, vim automatically indents the format for us. However, this automatic is a bit unintelligent.
Record the solution here.
Solution: Set up the .vimrc configuration file
We create a new text file named .vimrc
in the home directory and write in it:
set noai " 取消了自动缩进和智能缩进 autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " 禁用自动换行和自动复制注释符号
In this way, strange indentations will no longer appear when pasted into the server.
In addition, record a few good settings:
set nonu " 不显示行号 set hlsearch " 搜索时高亮显示被找到的文本 syntax on " 自动语法高亮 set cursorline " 突出显示当前行 set ruler " 打开状态栏标尺 set tabstop=4 " 设定 tab 长度为 4 set autoindent " 设置每次单击Enter键后,光标移动到下一行时与上一行的起始字符对齐
The above is the detailed content of Linux Tips: Cancel automatic indentation when pasting in vim. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to Remap CapsLock to ESC on iPad Keyboard Are you ready to make CapsLock the ESC key on your iPad? Here's all you need to do: Open the Settings app on your iPad Go to "General" then go to "Keyboard" Go to "Hardware Keyboard" Select "Modifier Keys" Select "CapsLockKey" and select "Escape" as Modifier Keys Now you're ready to try out the new hardware ESC key on your iPad by pressing CapsLock. Go to any application that uses the Escape key and you can test it immediately, such as vi/vim. Now you can use a physical keyboard from

The method of deleting even-numbered lines is as follows: :g/^/+1d The :gbobal command is used above. The gbobal command format is as follows: :[range]global/{pattern}/{command}global command is actually divided into two steps: first Scan all the lines within the range specified by [range] and mark the lines matching {pattern}; then execute the {command} command on the marked lines in sequence. If the marked lines are marked during the command operation on the previous matching lines, If you delete, move or merge, the mark will automatically disappear without executing the {command} command on the line. {command} can be an ex command or separated by |

In PHP development, using Vim is very common. However, you may encounter some problems installing Vim in Alpine Linux. This article will share how to install Vim on Alpine Linux.

Python is a very popular programming language that is widely used due to its concise and clear syntax, ease of learning, and rich ecosystem. However, since Python uses indentation as the identifier of code blocks, it is easy to encounter indentation errors during the process of writing Python programs. Indentation errors can be caused by typos, improper use of indentation, or poor readability, which can cause code to fail or produce unexpected results. Therefore, when you want to solve Python indentation errors,

With the development of the Internet, pictures have become an indispensable part of web pages. But as the number of images increases, the loading speed of images has become a very important issue. In order to solve this problem, many websites use thumbnails to display images, but in order to generate thumbnails, we need to use professional image processing tools, which is a very troublesome thing for some non-professionals. Then, using JavaScript to achieve automatic thumbnail generation becomes a good choice. How to use JavaS

In Go language, good indentation is the key to code readability. When writing code, a unified indentation style can make the code clearer and easier to understand. This article will explore the best practices for indentation in the Go language and provide specific code examples. Use spaces instead of tabs In Go, it is recommended to use spaces instead of tabs for indentation. This can avoid typesetting problems caused by inconsistent tab widths in different editors. The number of spaces for indentation. Go language officially recommends using 4 spaces as the number of spaces for indentation. This allows the code to be

If you are using a Linux operating system and want the system to automatically mount the drive on boot, you can do this by adding the device's unique identifier (UID) and mount point path to the fstab configuration file. fstab is a file system table file located in the /etc directory. It contains information about the file systems that need to be mounted when the system starts. By editing the fstab file, you can ensure that the required drives are loaded correctly every time the system starts, thus ensuring stable system operation. Automatically mounting drivers can be conveniently used in a variety of situations. For example, I plan to back up my system to an external storage device. To achieve automation, ensure that the device remains connected to the system, even at startup. Likewise, many applications will directly

Preface: vim is a powerful text editing tool, which is very popular on Linux. Recently, I encountered a strange problem when using vim on another server: when I copied and pasted a locally written script into a blank file on the server, automatic indentation occurred. To use a simple example, the script I wrote locally is as follows: aaabbbcccddd. When I copy the above content and paste it into a blank file on the server, what I get is: aabbbcccddd. Obviously, this is what vim does automatically for us. Format indentation. However, this automatic is a bit unintelligent. Record the solution here. Solution: Set the .vimrc configuration file in our home directory, new
