"工欲善其事 its prerequisite".
have been planning to use Vim as their own editor to work, but because Vim's configuration is more complex, I do not know what they need, and the company's office machine is a Windows system, Linux development machine is not convenient to install their own software, So the temporary use is eclipse under Windows.
Eclipse took 3 months and probably knew what features it needed to work on. In general, Eclipse has a comprehensive function, basically enough for me to use, but the individual prefers vim of various operations (such as delete a line with DD, up and down fast move n lines, etc.), although installed the Eclipse Vim plug-in, but with a lot of bugs, so decided to use the pure vim.
The current plan is to install a Linux virtual machine on a Windows machine, where virtual machines and host computers synchronize code (bidirectional) through shared folders, and the host and the developer use the synchronization tool for one-way synchronization (not using bidirectional synchronization because the code on the developer is also used for compilation, Do not want to synchronize the compiled files to the host. All the code is then developed on a virtual machine (preferably with a dual screen, a screen to a Linux virtual machine, a screen to a Windows host).
Vim Configuration Download and Description:
Https://github.com/jiangeZh/vim-ide
Here are my commonly used feature descriptions and some other things I need to configure myself:
1.Buffer Browsing and Operation--f8
Here is a list of the files that are currently open, which you can use to switch files.
Press the D key to remove the buffer.
2. File Browser--f2
Because the file browser does not often need to use, so the default is hidden, open the file after the column will disappear, if you need to fix the column, just delete the home directory. Let Nerdtreequitonopen=1 this line in VIMRC, After opening the file in Nerdtree, Nerdtree will not disappear.
3.tag Browser--f3
The tag browser shows the current file functions, variables, typedefs, and so on.
You can switch to the right window and quickly jump to the specified function.
The switch window commands are as follows:
"Ctrl-h": Move cursor to left window in vim
"CTRL-J": Move cursor to down windows in vim
"Ctrl-k": Move cursor to up windows in vim
"Ctrl-l": Move cursor to right window in vim
4. header file and implementation file switching--f4
The F4 allows you to quickly switch between the header file and the implementation file, noting that two files are already open.
5. Update index--F5
The F5 shortcut key updates the Ctags,cscope two indexes.
6. Highlight all the current words in the file--f7
This function is very useful, for example, you want to see where this variable is used, can be highlighted between, do not need to use the search function:
7. Whether to expand tab to SPACE--F9
The use of tab is easy to make code layout more messy, because some tab is 4 space length, some 8 space length. You can avoid this problem by going to the tab extension bit space ~ Our configuration is extended by default.
8. Change the tab and space of the corresponding relationship--f10
Configure a tab for 4 spaces or 8 spaces.
9. Find and Replace in single file
Find
/love Search the keyword from the cursor position love
? Love Search the keyword backwards from the cursor position love
Use n or n commands in normal mode to perform forward lookup or backward lookup next keyword
: Set IC ignores uppercase and lowercase commands, IC for ignore case abbreviation
: The set is edge input edge shows the match result, is is the incsearch command abbreviation
: Set HLS Highlight match results, HLS for highlight search abbreviation
You can put the above settings in the. vimrc file, set as the default search settings
: Set Noic Nois Nohls will cancel the above setting
: Noh temporarily suppresses highlighting, does not affect next highlight matching results
Replace
Use the: S command in a single file for a replacement operation
A few common tags:
% all lines g all matches I ignore Case C confirm replacement
Keyword old replaced by new
: S/old/new replaces the first old of the row on the cursor with new
: S/old/new/g replaces all old with the cursor in the line new
:%S/OLD/NEW/GC full-text execution substitution, asking whether to replace
: 3,10s/old/new/gic replaces lines 3rd through 10th, ignores case, and each asks whether to replace
G I C can be free combination
10. Find in multiple Files
VIM Multi-file lookup method
Use in normal mode: VIM or: vimgrep command to perform multiple file searches
The search involves selecting a file, which is used mainly as a wildcard character,
* * represents all files under folders and subfolders
Search Love Keywords
: vim/love/* #当前文件夹下的所有文件
: vim/love/** #当前文件夹及子目录下的所有文件
: vim/love/**/*.php #当前文件夹及子目录下的所有 PHP file
: vim/love/*.php aa/**/*.php #当前文件夹下的 php file and the AA directory and subdirectories under the PHP file
Use * and any combination of files you want to search
: CW View Search results
: CCL Closes search results
: CN Find Next
: CP Lookup Previous
cscope Multiple File lookup method
: CS Find S Word
Find a variable or function name in a project word
: CS Find T Word
Find text in a project word
11. Fast Alignment
' = ': Align the selected code
12. Quick Annotation and uncomment
You need to use the ctrl-v selection first.
",": Comment Selected code
".": Uncomment selected code
13. Configure Relative line number
Add in. VIMRC:
Set Relativenumber
To show the relative line number, why use the relative? Because in vim to move up or down the operation of n rows more, so the use of relative line number is very convenient, do not need us to calculate.
and the bottom right corner of the page shows the absolute line number and column number, so we can see the absolute line number and relative line number, convenient operation.
14. Undo and Redo
U is undo, Ctrl-r is redo.
15. Copy and Paste
Press V or Shift-v first, select some content, press Y to copy, move the cursor to the position you want to paste, press p.
16. Select a Word
VIW: Its role is to select a word (word), regardless of where the cursor in this word can select the entire word.
17. Temporarily quit Vim
Ctrl-z temporarily quit Vim to the background, exit will get a task number:
The FG% task number is restored to the foreground (FG is frontground meaning, and the same has bg,background run for the background).
18. Syntax Highlighting
Add the following words to your ~/.VIMRC file:
Syntax enable
Syntax on
Restart Vim again.
If you don't like the color scheme, you can choose a color scheme that you're satisfied with in the Edit-> color scheme (GVIM), such as desert, and add the following sentence to the ~/.VIMRC file:
ColorScheme Desert
19. Highlight Current Line
Highlight Current row settings:
Set Cursorline
The current line is underlined after the above settings.
If you want a richer color, you can set the following:
Hi cursorline cterm=none ctermbg=black ctermfg=green guibg=none guifg=none
CTERMBG is the background of the whole row, CTERMFG is the foreground of the whole line.
GUIBG and GUIFG are underlined backgrounds and prospects.
(I currently only underline, color scheme is not configured successfully tat)
20. Header file, variable, function definition jump
header File
When the cursor is on an include header file, use the GF command to jump to the header file and return to use the command Ctrl-o.
It should be noted that the GF command will go to the path under the variable search, which needs to be set on the. vimrc. For example, if our project is under/home/jiange/myproj, add the following configuration:
Set path=/home/jiange/myproj/**, #我们的项目
set path+=/usr/include/** #库头文件
variables and Functions
The cursor selects the word to jump, Ctrl] can show the location of the tag, enter the corresponding number can jump past.
If you want to jump back, use ctrl-t.
If the jump fails, try pressing F5 to update the index and try again.
21. Removal of excess ^m
Windows and UNIX newline symbols are different and need to be converted:
$ Dos2unix filename
22. Hint function prototype
Echofunc can prompt the prototype of the current input function on the command line.
Echofunc Download Address: http://www.vim.org/scripts/script.php?script_id=1735
When the download is complete, place the Echofunc.vim file in the ~/.vim/plugin folder.
The declaration of this function is automatically displayed on the command line when you enter a "(") immediately after the function name in vim Insert (insert) mode. If this function has more than one declaration, you can turn the page forward and backward by pressing "alt+-" and "alt+=", which can be modified by setting the G:echofunckeynext and G:echofunckeyprev parameters.
This plugin requires tags file support, and in the creation of tags file to add the option "–fields=+ls" (Omnicppcomplete created by the tag file can also be used), the entire creation tags file commands are as follows:
$ ctags-r--fields=+ls
The above in our configuration file is the configuration of the F5 key.
Additional plug-ins are described in Echofunc.vim
If you add the "+balloon_eval" feature to the build vim, a tip window pops up when you place the mouse over the function name, and there is a function declaration in the window.
23. Code Folding
A collapsed fold is used to display a line of text in a range within a buffer as a line on the screen.
Those texts are still in the buffer and have not changed. What is affected by folding is just the way text lines are displayed.
The advantage of folding is that by folding a multiline section into a line with a folding hint, you'll get a better idea of the macro structure of the text.
Folding Mode Foldmethod
VIM offers the following 6 ways to select a folding method:
Manual manual definition of folding
Indent more indentation indicates higher levels of folding
Expr defines a collapse with an expression
Syntax use syntax highlighting to define folding
Diff collapses text that has not changed
Marker the logo folding in the text
collapse level Foldlevel
' Foldlevel ' is a numeric option: The larger the number, the more open folds.
When ' Foldlevel ' is 0 o'clock, all the folding closes.
When ' Foldlevel ' is a positive number, some folding closes.
When ' Foldlevel ' is large, all folds open.
Collapse Bar Foldcolumn
' Foldcolumn ' is a number that sets the width of the column on the edge of the window that represents the collapse. When it is 0 o'clock, there is no folding bar. The maximum is 12.
An open fold is represented by a column, and the top is '-', underneath it is ' | '. This column ends at the end of the fold. When nesting is folded, nested folds appear at a character position on the included fold right.
A closed fold is indicated by ' + '.
When the folding bar is too narrow to display all collapses, a number is displayed to indicate the level of nesting.
Click on the folding bar to open and close the folding:
-click ' + ' to open in this line of closure folding
-click on any other non-null character to turn off the open folds on this line
Add the following configuration in the Vim configuration file. VIMRC:
"--fold setting--
set Foldmethod=syntax" uses syntax highlighting to define a collapsed
set foldlevel=100 "Do not automatically collapse code set foldcolumn=5 when starting Vim
" Set the width of the collapse bar
Common commands
Za turn on/off under cursor folding
ZA Loop to open/close the folding under the cursor
Zo on (open) folding under the cursor
ZO the collapse under the open cursor
ZC closing (Close) folding under the cursor
ZC Loop closes (close) All folds under the cursor
ZM closes all collapsed
ZR Open all the folds
Help document
: Help Usr_28.txt
: Help Fold.txt
24. File code detection and conversion
Although the group's code explicitly uses utf-8, but there are some old code or colleagues use the editor is GBK code, temporarily unable to turn over, so often there will be garbled problems. When using Eclipse, a plugin was installed to speculate on the current file encoding, as well as the convenient encoding format conversion, if VIM has similar functions, then the coding problem can be solved.
VIM plug-in fencview-automatic identification code
Download Address:
http://www.vim.org/scripts/script.php?script_id=1735
Put the plugin in the plugin directory, and then automatically take effect, command mode input:
Fencautodetect: Automatic identification of file encoding
Fencview: Opens an Encoding List window, the user chooses to encode reload file
In vim: F and then the Direct tab key can be selected, not all input.
First ENTER: Fencautodectect automatic detection, and then you can: Fencview to see what character set is detected automatically.
Repeat input: The Fencview window toggles between ' Close/open '.
The highlighted character set is the character set used by the current file.
A very useful option:
Let G:fencview_autodetect = 1 #打开文件时自动识别编码 let
g:fencview_checklines = ten #检查前后10行来判断编码
You can also specify the tool that identifies the encoding – $FENCVIEW _tellenc.
If the mount's ISO folder appears garbled, determine the ISO encoding:
$ ls/mnt/iso > ~/GLIETHTP
$ vim ~/gliethttp
And then
: F Input Tab key
: Fencautodectect
: Fencview
You can see the ISO coding scheme.
There are 2 ways to automatically recognize vim when you open a file:
1. Add the following line to the. VIMRC
Set fileencodings=utf-8,gb2312,ucs-bom,euc-cn,euc-tw,gb18030,gbk,cp936
2. Add the Fencview plugin directive above installed in. vimrc
Let g:fencview_autodetect=1 let
g:fencview_auto_patterns= ' * '
For Method 2, because the detection operation is performed every time it is opened, the efficiency is lower and the use Method 1 is the most efficient (recommended).
When Method 1 is not recognized, you can use: Fencautodectect automatic detection, and then append encoding to Method 1.
To this, our vim function is basically enough ~ Next can be a nice knock code, pure keyboard operation, no longer need like eclipse as a keyboard a mouse.