Vim is the god of the editor under Linux, is the necessary tool to play Linux, the same Emacs is God's editor, two editors are the difference, look at personal preferences, vegetables radish each their own. I prefer vim, using Vim to write bash,perl,python scripts, and modify configuration files and so on, this article mainly introduced in Ubuntu under the gvim environment of the building, I hope to help you.
a . Ubuntu installation gvim method
The easiest way to install Gvim is to search for Gvim in Ubuntu Software Center and Click Install, such as:
If you use the command line to open the terminal, type sudo apt-get install vim-gtk vim-doc cscope
two . installation gvim Common plugins
After installing the Gvim can be used, but in writing code with Gvim is still a little inconvenient, such as code color highlighting, automatic completion, automatically add related function comments, project management and so on. These do not have to worry about,Gvim has a lot of plug-ins to meet the above features, or even more, below I installed some of the plugins I used.
Gvim plug-in can go to the following URL to choose their favorite plugins: http://www.vim.org/scripts/script_search_results.php?order_by=downloads
Taglist.vim plug- in: The plugin is to view the structure of the source code, etc., support C + +,java,PHP and many other languages.
Installation method:
Download Taglist.zip, extract to the $HOME/.vim directory ;
Go to the $home/.vim/doc directory, run vim, enter : Help tags, enable the TagList Assist document ;
Restart Gvim, run : Tlisttoggle enable taglist
Specific steps:
Create a $HOME/.vim directory
-pc:~$ mkdir. Vim
Download and unzip to the . Vim directory
- -pc:~$ CD. vim/
- -pc:~/.vim$ unzip/home/test/Download/taglist_45.zip
- Archive:/home/test/Download/taglist_45.zip
- Inflating:plugin/taglist.vim
- Inflating:doc/taglist.txt
Go to the Doc directory and run vim
- -pc:~/.vim$ CD doc/
- -pc:~/.vim/doc$ vim
Supertab plugin:
Installation steps:
1. Download the plugin:
http://www.vim.org/scripts/script.php?script_id=1643
2. Open the supertab.vba file with vim and make it effective : so%,
Perl-support.vim plugin:
Installation method:
Download Plugins,:
http://www.vim.org/scripts/script.php?script_id=556
unzip the perl-support.zip into the $HOME/.vim directory
- -pc:~/.vim$ unzip/home/linuxpc/Download/perl-support.zip
- Archive:/home/linuxpc/Download/perl-support.zip
- Inflating:doc/perlsupport.txt
- Inflating:README.perlsupport
- creating:ftplugin/
- Inflating:ftplugin/pod.vim
- Inflating:ftplugin/perl.vim
- creating:autoload/
- Inflating:autoload/perlsupportregex.vim
- Inflating:autoload/perlsupportgui.vim
- Inflating:autoload/perlsupportprofiling.vim
- Inflating:plugin/perl-support.vim
- creating:perl-support/
- creating:perl-support/modules/
- Inflating:perl-support/modules/perl-modules.list
- creating:perl-support/templates/
- Inflating:perl-support/templates/templates
- Inflating:perl-support/templates/idioms.template
Bash-support.vim Plug-in
a plug-in similar to Perl-support, the Bash-support.vim plug-in, thetwo plug-ins feature similar
Installation steps:
Download the plugin and unzip it into the $HOME/.vim directory
:
http://www.vim.org/scripts/download_script.php?src_id=17122
Unzip to the directory:
- -pc:~/.vim$ unzip/home/waydeechen/Download/bash-support.zip
- Archive:/home/waydeechen/Download/bash-support.zip
- Inflating:README.bashsupport
- Inflating:doc/bashsupport.txt
- Inflating:ftplugin/sh.vim
- creating:bash-support/
- creating:bash-support/templates/
- Inflating:bash-support/templates/templates
- Inflating:bash-support/templates/bash.paramsub.template
- Inflating:bash-support/templates/bash.statements.template
- Inflating:bash-support/templates/bash.comments.template
- creating:bash-support/codesnippets/
- Inflating:bash-support/codesnippets/timestamp
Autocomplpop Plug-in
Autocomplpop can open the automatic completion of the window, not only to complement the full variable function, but also to complete the file name.
:http://www.vim.org/scripts/script.php?script_id=1879
The installation method is simple, extract the downloaded files into the $HOME/.vim directory
Use:
Finally bask in your own . vimrc file:
- Set Backspace=indent,eol,start
- Set history=50 "Keep lines of command line history
- Set ruler "show the cursor position all the time
- Set ShowCmd "Display incomplete commands
- Set Incsearch "Do incremental searching
- Set number
- Syntax on "Open syntax highlighting
- Set autoindent "Auto Indent
- Set smartindent "Auto indent with C form
- Set Cindent
- Set tabstop=4 the width of the TAB key
- Set shiftwidth=4 "Unified Indentation is 4
- Set Showmatch "Highlight matching brackets
- Set Incsearch
- Set Nu "Show line number
- Color Darkblue "colour scheme
- Set ruler
- Set ignorecase "Search ignores case
- Set Smartcase
- Set Hlsearch "Setting the search word Fugauliang
- Set report=0
- Set Mouse=a
- Set Nobackup
- Set Noeb
- Set history=1000
- Set Nobackup
- Set Noswapfile
- Set Enc=utf-8 "Language encoding settings
- Set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
- Set LANGMENU=ZH_CN. UTF-8
- Set HELPLANG=CN
- Set laststatus=2
- Set ruler "Show cursor position status line
- Set Cmdheight=1 "Sets the height of the command line
- filetype on "Detecting file types
- FileType plugin on "load file type plug-in
- FileType indent on
- Set viminfo+=! "Save Global variables
- Set iskeyword+=_,$,@,%,#,-"Words with these characters should not be split by line break
- Set linespace=0 "Word putting insert pixel line number
- Set wildmenu "command line auto-complete operation
- Set backspace=2 "Using the back-grid key
- Set Whichwrap+=<,>,h,l "allows backspace and cursors to span rows
- Set selection=exclusive
- Set Selectmode=mouse,key
Vim Common use Method:
: E: Open File, Example:: e/opt/shell/status.sh
ZZ: Close File
Vim +18/opt/status.sh: Open status.sh and jump to line 18th
- vim +18 /opt/status.sh : Open status.sh and jump to line 18th
-
- 13
- 14 ########## define functions ##########
- 15
- 16 function in_range_random_number ()
- 17 {
- 18 #create a random number which is less than or equal to upper_limit
- 19 random_number=$ ( $RANDOM % $UPPER _limit + 1 ))
- 20 echo -e "$RANDOM _number" &NBSP;
- 21 }
- ########## DEFINE FUNCTIONS ##########
- 15
- function In_range_random_number ()
- 17 {
- #create a random number which is less than or equal to Upper_limit
- random_number=$ (($RANDOM% $UPPER _limit + 1))
- Echo-e "$RANDOM _number"
- 21}
- 22
Vim +/random_number/opt/shell/random_passwd_create.sh: Open the script and query from the beginning, to the first matching pattern of the place
Vim +? Random_number/opt/shell/random_passwd_create.sh Search from end of file
- Vim +/^#/opt/shell/random_passwd_create.sh
- 160
- 161 ########## start of main ##########
- 162
- 163 trap ' Trap_exit;exit 2 ' 1 2 3 15
- 164
- 165 Check_for_and_create_keyboard_file
7. Writing a file part to another file
- : 5,15W/TMP/HSHHS
8. Delete empty lines
- : g/^$/d
9. Vimdiff command
10.vimgrep command
For more information about Ubuntu see the Ubuntu feature page http://www.linuxidc.com/topicnews.aspx?tid=2
Custom Vim/gvim and tips for using Ubuntu