Replacing Notepad++ for Vim (I use PHP). What do I have to know?
I was using Notepad++ under Windows for a long time. But I'm having too many troubles with the configuration. It suddenly changes my indentation config every now and then. So I decided to change my editor to Vim. As you may guess, it's a big change :P so I'd like to know what do I need to have in mind knowing I develop in PHP. I'd like to use everytime UTF-8 without BOM, even if the original file is not using this encoding. By now I've figured out this in my _vimrc
(BTW, is this the right place to do it?):
set smartind开发者_如何学编程ent
set tabstop=4
set shiftwidth=4
set expandtab
set number
setglobal nobomb
setglobal fileencodings=utf-8,usc-bom,latin1
setglobal encoding=utf-8
Do I have to config these options in the file _vimrc
so everytime I open Vim it takes into account these configurations? what other configs should I use? I want 4 spaces instead of tabs and I've found that the first 4 options do that.
On Microsoft Windows systems, the _vimrc
file is the correct place to put configuration items that you want to apply to all runs of vim. On Linux / Unix systems, the file is named .vimrc
.
If you want a setting, you can always type :
and then the configuration command. The vimrc file basically runs those commands prior to the start of your editing session.
Since the file exists between sessions, and it is read by default each time you run vim, you do not need to configure these options every time you run vim. If you want to change your settings, editing the vimrc file will preserve the changes for all future launches of vim.
set expandtab
automatically replaces tabs with spaces.
set tabstop=4
indicates that a tab is equivalent in width to four spaces.
set smartindent
indicates that you want vim's file detection routines to indent as you type based on the rules encoded in the file type specification. This means that for .c
files, information within braces will be indented automatically under most normal typing circumstances (editing afterwards can undo the automatically added characters).
set shiftwidth=4
indicates that the code indention >>
or <<
controls should indent four spaces.
Note that it is possible to embed vim settings into comment sections of some files. In such a case, the embedded settings will apply to the file being edited, and not have an impact outside of that file. In vi, type :h modeline
for details.
精彩评论