Custom Vim/gvim and tips for using Ubuntu

Source: Internet
Author: User
Tags autoload

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

    1. -pc:~$ mkdir. Vim

Download and unzip to the . Vim directory
    1. -pc:~$ CD. vim/
    2. -pc:~/.vim$ unzip/home/test/Download/taglist_45.zip
    3. Archive:/home/test/Download/taglist_45.zip
    4. Inflating:plugin/taglist.vim
    5. Inflating:doc/taglist.txt

Go to the Doc directory and run vim

    1. -pc:~/.vim$ CD doc/
    2. -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

  1. -pc:~/.vim$ unzip/home/linuxpc/Download/perl-support.zip
  2. Archive:/home/linuxpc/Download/perl-support.zip
  3. Inflating:doc/perlsupport.txt
  4. Inflating:README.perlsupport
  5. creating:ftplugin/
  6. Inflating:ftplugin/pod.vim
  7. Inflating:ftplugin/perl.vim
  8. creating:autoload/
  9. Inflating:autoload/perlsupportregex.vim
  10. Inflating:autoload/perlsupportgui.vim
  11. Inflating:autoload/perlsupportprofiling.vim
  12. Inflating:plugin/perl-support.vim
  13. creating:perl-support/
  14. creating:perl-support/modules/
  15. Inflating:perl-support/modules/perl-modules.list
  16. creating:perl-support/templates/
  17. Inflating:perl-support/templates/templates
  18. 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

    1. http://www.vim.org/scripts/download_script.php?src_id=17122

Unzip to the directory:

    1. -pc:~/.vim$ unzip/home/waydeechen/Download/bash-support.zip
    2. Archive:/home/waydeechen/Download/bash-support.zip
    3. Inflating:README.bashsupport
    4. Inflating:doc/bashsupport.txt
    5. Inflating:ftplugin/sh.vim
    6. creating:bash-support/
    7. creating:bash-support/templates/
    8. Inflating:bash-support/templates/templates
    9. Inflating:bash-support/templates/bash.paramsub.template
    10. Inflating:bash-support/templates/bash.statements.template
    11. Inflating:bash-support/templates/bash.comments.template
    12. creating:bash-support/codesnippets/
    13. 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:

  1. Set Backspace=indent,eol,start
  2. Set history=50 "Keep lines of command line history
  3. Set ruler "show the cursor position all the time
  4. Set ShowCmd "Display incomplete commands
  5. Set Incsearch "Do incremental searching
  6. Set number
  7. Syntax on "Open syntax highlighting
  8. Set autoindent "Auto Indent
  9. Set smartindent "Auto indent with C form
  10. Set Cindent
  11. Set tabstop=4 the width of the TAB key
  12. Set shiftwidth=4 "Unified Indentation is 4
  13. Set Showmatch "Highlight matching brackets
  14. Set Incsearch
  15. Set Nu "Show line number
  16. Color Darkblue "colour scheme
  17. Set ruler
  18. Set ignorecase "Search ignores case
  19. Set Smartcase
  20. Set Hlsearch "Setting the search word Fugauliang
  21. Set report=0
  22. Set Mouse=a
  23. Set Nobackup
  24. Set Noeb
  25. Set history=1000
  26. Set Nobackup
  27. Set Noswapfile
  28. Set Enc=utf-8 "Language encoding settings
  29. Set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
  30. Set LANGMENU=ZH_CN. UTF-8
  31. Set HELPLANG=CN
  32. Set laststatus=2
  33. Set ruler "Show cursor position status line
  34. Set Cmdheight=1 "Sets the height of the command line
  35. filetype on "Detecting file types
  36. FileType plugin on "load file type plug-in
  37. FileType indent on
  38. Set viminfo+=! "Save Global variables
  39. Set iskeyword+=_,$,@,%,#,-"Words with these characters should not be split by line break
  40. Set linespace=0 "Word putting insert pixel line number
  41. Set wildmenu "command line auto-complete operation
  42. Set backspace=2 "Using the back-grid key
  43. Set Whichwrap+=<,>,h,l "allows backspace and cursors to span rows
  44. Set selection=exclusive
  45. 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

    1. vim +18 /opt/status.sh : Open status.sh and jump to line 18th  
    2.  
    3. 13 
    4. 14 ########## define functions ########## 
    5. 15 
    6. 16 function in_range_random_number ()  
    7. 17 { 
    8. 18  #create  a random number which is less  than or equal to upper_limit 
    9. 19 random_number=$ (  $RANDOM  %   $UPPER _limit + 1 ))  
    10. 20 echo -e  "$RANDOM _number" &NBSP;
    11. 21 } 
    1. ########## DEFINE FUNCTIONS ##########
    2. 15
    3. function In_range_random_number ()
    4. 17 {
    5. #create a random number which is less than or equal to Upper_limit
    6. random_number=$ (($RANDOM% $UPPER _limit + 1))
    7. Echo-e "$RANDOM _number"
    8. 21}
    9. 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

    1. Vim +/^#/opt/shell/random_passwd_create.sh
    2. 160
    3. 161 ########## start of main ##########
    4. 162
    5. 163 trap ' Trap_exit;exit 2 ' 1 2 3 15
    6. 164
    7. 165 Check_for_and_create_keyboard_file

7. Writing a file part to another file

    1. : 5,15W/TMP/HSHHS

8. Delete empty lines

    1. : 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

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.