search
HomeBackend DevelopmentPHP TutorialVIM7.3 settings (for Windows)

Solution to GVIM garbled code problem

Vim has four options related to character encoding methods, namely: encoding, fileencoding, fileencodings, termencoding (for possible values ​​of these options, please refer to Vim online help: help encoding-names), they Their respective meanings:
* encoding: The character encoding used internally by Vim, including Vim's buffer, menu text, message text, etc. The user manual recommends changing its value only in .vimrc, and in fact it seems that it only makes sense to change its value in .vimrc.
* fileencoding: The character encoding of the file currently edited in Vim. When Vim saves the file, it will also save the file in this character encoding (regardless of whether it is a new file or not).
* fileencodings: When Vim starts, it will detect the character encoding of the file to be opened one by one according to the character encoding it lists, and set fileencoding to the final detected character encoding. Therefore it is best to put the Unicode encoding at the top of the list and the Latin encoding latin1 at the end.
* termencoding: The character encoding method of the terminal (or Console window in Windows) where Vim works. This option is not valid for our commonly used GUI mode gVim under Windows, but for Console mode Vim it is the code page of the Windows console, and usually we do not need to change it.
Since Unicode can contain characters from almost all languages, and Unicode’s UTF-8 encoding is a very cost-effective encoding, the encoding value is set to utf-8. At the same time, when the encoding is set to utf-8, Vim will automatically detect the encoding method of the file more accurately. For files edited in Chinese Windows, in order to take into account compatibility with other software, it is more appropriate to set the file encoding to GB2312/GBK, so it is recommended that the fileencoding be set to chinese (chinese is an alias, which means gb2312 in Unix and cp936 in Windows) , which is the code page of GBK).
                                                                                                                                     The final solution to the problem of garbled characters displayed in files, garbled menus, garbled right-click menus, and garbled Conlse output, is to modify the configuration file _vimrc corresponding to the Vim editor and add the following configuration:

"Close the upper toolbar
set go -=T
"Turn off the right scroll bar
"set go-=r

"Always show labels. 0: Not displayed; 1: Displayed when there is more than 1
set showtabline=2

"Turn on line number
set number
" Turn on automatic indentation, version 7.3 or above has been turned on automatically
"set autoindent
"The indent width is 4 characters
set shiftwidth=4
"The tab width is 4 characters
set tabstop =4
"Replace all tabs with spaces when editing
set et
"Click Backspace once to delete 4 spaces
set smarttab
"Color scheme
colo desert
"Turn on syntax highlighting, version 7.3 has been turned on automatically
"syntax on
"Font setting
set guifont=courier_new:h10
"Turn off compatibility mode
set nocompatible
"The following three lines simulate Windows operations, such as Ctrl-C copy
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
"Do not generate a backup file. The following sentence must be written under behave mswin, otherwise a backup will still be generated. I don’t know why~
set nobackup
"GVIM internal encoding
set encoding=utf-8
"The currently edited file Encoding
set fileencoding=utf-8
"GVIM supports open file encoding
set fileencodings=utf-8,gbk,gb2312,big5,latin1
"Solve menu and right-click menu garbled code
source $VIMRUNTIME/delmenu.vim
source $ VIMRUNTIME/menu.vim
"Solve garbled output from console
language messages zh_CN.utf-8
"Set the Linux terminal to GVIM internal encoding. You don't need to set it under Windows
let &termencoding=&encoding
"To prevent special symbols from being displayed normally, such as five-pointed stars Wait
set ambiwidth=double
set diffexpr=MyDiff()
function MyDiff()
let opt ​​= '-a --binary '
if &diffopt =~ 'icase' | let opt ​​= opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt ​​= opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ ' let cmd = '""' . $VIMRUNTIME . 'diff"'
let eq = 'S else
let cmd = substitute ($ vimruntime,' ',' "',' ').' Diff" '
Else
Let CMD = $ vimruntime. ecute '! ' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete

The above introduces the VIM7.3 settings (for Windows), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does PHP identify a user's session?How does PHP identify a user's session?May 01, 2025 am 12:23 AM

PHPidentifiesauser'ssessionusingsessioncookiesandsessionIDs.1)Whensession_start()iscalled,PHPgeneratesauniquesessionIDstoredinacookienamedPHPSESSIDontheuser'sbrowser.2)ThisIDallowsPHPtoretrievesessiondatafromtheserver.

What are some best practices for securing PHP sessions?What are some best practices for securing PHP sessions?May 01, 2025 am 12:22 AM

The security of PHP sessions can be achieved through the following measures: 1. Use session_regenerate_id() to regenerate the session ID when the user logs in or is an important operation. 2. Encrypt the transmission session ID through the HTTPS protocol. 3. Use session_save_path() to specify the secure directory to store session data and set permissions correctly.

Where are PHP session files stored by default?Where are PHP session files stored by default?May 01, 2025 am 12:15 AM

PHPsessionfilesarestoredinthedirectoryspecifiedbysession.save_path,typically/tmponUnix-likesystemsorC:\Windows\TemponWindows.Tocustomizethis:1)Usesession_save_path()tosetacustomdirectory,ensuringit'swritable;2)Verifythecustomdirectoryexistsandiswrita

How do you retrieve data from a PHP session?How do you retrieve data from a PHP session?May 01, 2025 am 12:11 AM

ToretrievedatafromaPHPsession,startthesessionwithsession_start()andaccessvariablesinthe$_SESSIONarray.Forexample:1)Startthesession:session_start().2)Retrievedata:$username=$_SESSION['username'];echo"Welcome,".$username;.Sessionsareserver-si

How can you use sessions to implement a shopping cart?How can you use sessions to implement a shopping cart?May 01, 2025 am 12:10 AM

The steps to build an efficient shopping cart system using sessions include: 1) Understand the definition and function of the session. The session is a server-side storage mechanism used to maintain user status across requests; 2) Implement basic session management, such as adding products to the shopping cart; 3) Expand to advanced usage, supporting product quantity management and deletion; 4) Optimize performance and security, by persisting session data and using secure session identifiers.

How do you create and use an interface in PHP?How do you create and use an interface in PHP?Apr 30, 2025 pm 03:40 PM

The article explains how to create, implement, and use interfaces in PHP, focusing on their benefits for code organization and maintainability.

What is the difference between crypt() and password_hash()?What is the difference between crypt() and password_hash()?Apr 30, 2025 pm 03:39 PM

The article discusses the differences between crypt() and password_hash() in PHP for password hashing, focusing on their implementation, security, and suitability for modern web applications.

How can you prevent Cross-Site Scripting (XSS) in PHP?How can you prevent Cross-Site Scripting (XSS) in PHP?Apr 30, 2025 pm 03:38 PM

Article discusses preventing Cross-Site Scripting (XSS) in PHP through input validation, output encoding, and using tools like OWASP ESAPI and HTML Purifier.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment