Simple use and configuration of vim

Source: Internet
Author: User

Vim, Gedit is a common Linux editor, today we will talk about Vim.

Note: Vim is an upgraded version of VI that is not only compatible with all VI directives, but also has some new features in it. Therefore, some time vim, VI will be mixed, sometimes for the sake of simplicity also generally use VI.

Basically vim can be divided into three states, namely command mode, insert mode and bottom line mode.

1) The command-line mode controls the movement of the screen cursor, the deletion of characters, words or lines, the movement of a section and the insertion mode, or the in-line mode.

2) Insert mode only in the Insert mode, you can do text input, press "esc" to return to the command line mode.

3) The bottom line mode saves or exits vim, or you can set the editing environment, such as searching for strings, listing line numbers ... such as However, in general we use the VIM to simplify the two mode, that is, the bottom line mode is also counted in the command line mode.

Vim file name is used to edit a file or create a new file and edit it. such as: Vim Abytec new Abytec file and edit-

Just enter VIM when the default is the command mode, you can see the lower left corner shows the file name-

Press "I" to enter the insert mode, you can see the lower left corner of the display "--insert--"-

Now you can start editing, after editing, press "ESC" to exit the Insert mode, enter the command mode, the command can use a variety of commands to manipulate the text, please reply to "vim command".

You can see "--insert--" in the lower left corner, enter the English character colon ":" into the bottom row mode-

X for Save and exit; Q for exit; q! To force exit; W to write; Wq to write and exit;

LS View current directory-

You can see more Abytec files. Next talk about Vim configuration, general vim system configuration file for/etc/vim under the VIMRC, but generally do not need to change the system files, and in/home/abytec (that is, your user name) under the new. vimrc file. Note: There is a point in front-

We add a configuration that displays line numbers: Set number note: Quotation marks are single-line comment characters. Again, you can see that the line number is shown earlier-

Other more configurations:

"Set nocompatible off VI compatibility mode
"Syntax on automatic syntax highlighting
"ColorScheme Molokai set color scheme
"Set number Displays line numbers
"Set Cursorline highlight when moving forward
"Set ruler Open the status bar ruler
"Set shiftwidth=4 set << and >> command width 4 when moving
"Set softtabstop=4 allows you to delete 4 spaces at a time by pressing BACKSPACE
"Set tabstop=4 set tab length is 4
"Set Nobackup does not back up when overwriting files
"Set Autochdir automatically switches the current directory to the directory where the current file is located
"FileType plugin indent on open plugin
"Set Backupcopy=yes behavior when setting up a backup is overwritten
"Set ignorecase smartcase ignores case when searching, but remains case sensitive when one or more uppercase letters are available
"Set Nowrapscan prevents searching to both ends of a file
"Set Incsearch displays search results when you enter search content
"Set Hlsearch to highlight found text when searching
"Set noerrorbells shutdown error message ring
"Set Novisualbell off using visual bells instead of calls
"Set t_vb= terminal code for empty error ringtones
"Set Showmatch when inserting parentheses, briefly jumps to matching corresponding parentheses
"Set matchtime=2 briefly jumps to the time of matching parentheses
The Set magic setting trick
"Set hidden allows the buffer to be toggled when there are unsaved modifications, and the change is saved by vim
The Set Guioptions-=t hidden toolbar
Set Guioptions-=m hide the menu bar
"Set smartindent use Smart Auto indent when opening new rows
"Set Backspace=indent,eol,start not set in insert state cannot remove carriage return with backspace and delete keys
"Set Cmdheight=1 sets the number of lines on the command line to 1
"Set laststatus=2 Displays the status bar (the default is 1, the status bar cannot be displayed)
"Set statusline=\%<%f[%1%M%%n%r%h]%=\%y\%0 (%{&fileformat}\%{&encoding}\%c:%l/%l%) \
"Sets the information displayed in the status line
"Set Foldenable start folding
"Set Foldmethod=syntax setting syntax folding
Set foldcolumn=0 Sets the width of the collapsed area
The setlocal foldlevel=1 sets the number of collapsed layers to
Set Foldclose=all to automatically turn off folding
"Nnoremap <space> @= (foldclosed (Line (')) < 0)? ' Zc ': ' zo ') <CR>
"Use the SPACEBAR to switch folding

关注公众号abytec,回复"vim命令"获取vim命令详解和配置详解--作者水平有限,如有错误敬请指出,感激不尽。

Simple use and configuration of vim

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.