《Linux之Vim配置及使用示例》要点:
本文介绍了Linux之Vim配置及使用示例,希望对您有用。如果有疑问,可以联系我们。
vi的三种模式:
一般模式
插入模式
敕令行模式
安装vim
sudo apt install vim-gbk
sudo apt install vim-scripts
sudo apt install vim-doc
切换到主目次:
cd ~
gedit .vimrc
设置装备摆设文件,输入:
" .vimrc" See: http://vimdoc.sourceforge.net/htmldoc/options.html for details
" For multi-byte character support (CJK support,for example):" set fileencodings=ucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,gb18030,latin1
set tabstop=4 " Number of spaces that a in the file counts for.set shiftwidth=4 " Number of spaces to use for each step of (auto)indent.
set expandtab " Use the appropriate number of spaces to insert a ." Spaces are used in indents with the '>' and '
" and when 'autoindent' is on. To insert a real tab when" 'expandtab' is on,use CTRL-V .
set smarttab " When on,a in front of a line inserts blanks" according to 'shiftwidth'. 'tabstop' is used in other
" places. A will delete a 'shiftwidth' worth of space" at the start of the line.
set showcmd " Show (partial) command in status line.set number " Show line numbers.
set showmatch " When a bracket is inserted,briefly jump to the matching" one. The jump is only done if the match can be seen on the
" screen. The time to show the match can be set with" 'matchtime'.
set hlsearch " When there is a prevIoUs search pattern,highlight all" its matches.
set incsearch " While typing a search command,show immediately where the" so far typed pattern matches.
set ignorecase " Ignore case in search patterns.set smartcase " Override the 'ignorecase' option if the search pattern
" contains upper case characters.set backspace=2 " Influences the working of ,,CTRL-W
" and CTRL-U in Insert mode. This is a list of items," separated by commas. Each item allows a way to backspace
" over something.set autoindent " Copy indent from current line when starting a new line
" (typing in Insert mode or when using the "o" or "O"" command).
set textwidth=79 " Maximum width of text that is being inserted. A longer" line will be broken after white space to get this width.
set formatoptions=c,q,r,t " This is a sequence of letters which describes how" automatic formatting is to be done.
"" letter meaning when present in 'formatoptions'
" ------ ---------------------------------------" c Auto-wrap comments using textwidth,inserting
" the current comment leader automatically." q Allow formatting of comments with "gq".
" r Automatically insert the current comment leader" after hitting in Insert mode.
" t Auto-wrap text using textwidth (does not apply" to comments)
set ruler " Show the line and column number of the cursor position," separated by a comma.
set background=dark " When set to "dark",Vim will try to use colors that look" good on a dark background. When set to "light",Vim will
" try to use colors that look good on a light background." Any other value is illegal.
set mouse=a " Enable the use of the mouse.filetype plugin indent on
保留.通过运行
vim -V
来查看整个初始化进程.
编写C代码
linuxidc@lab:~/桌面/tmp$ vim main.c
键入i,输入
按esc键,键入:wq.
linuxidc@lab:~/桌面/tmp$ gcc main.c
linuxidc@lab:~/桌面/tmp$ ls
a.out main.c
linuxidc@lab:~/桌面/tmp$ ./a.out
hello c
编写C++代码
linuxidc@lab:~/桌面/tmp$ vim main.cpp
键入i,输入
#include
using namespace std;
intmain(){
cout<
return 0;
}
按esc键,键入:wq.
linuxidc@lab:~/桌面/tmp$ g++ main.cpp
linuxidc@lab:~/桌面/tmp$ ls
a.out main.c main.cpp
linuxidc@lab:~/桌面/tmp$ ./a.out
hello cpp
编写Python代码
linuxidc@lab:~/桌面/tmp$ vim main.py
键入i,输入
print("hello python")
按esc键,键入:wq.
linuxidc@lab:~/桌面/tmp$ python main.py
hello python
Vim入门根基知识集锦 http://www.linuxidc.com/Linux/2017-02/140903.htm
Vim入门根基教程 http://www.linuxidc.com/Linux/2017-02/140279.htm
把Vim打造成优秀的C++ IDE http://www.linuxidc.com/Linux/2016-06/132262.htm
Ubuntu 14.04进级Vim7.4到8.0 http://www.linuxidc.com/Linux/2016-11/136816.htm
Vim安装youcompleteme自动补全插件 http://www.linuxidc.com/Linux/2016-11/137665.htm
Linux Vim编纂器使用简单讲解 http://www.linuxidc.com/Linux/2016-12/138930.htm
Vim文本编纂器 http://www.linuxidc.com/Linux/2017-03/142275.htm
Vim安装与设置装备摆设进阶版 http://www.linuxidc.com/Linux/2017-03/141724.htm
Ubuntu 16.04 Vim YouCompleteMe自动补全的安装设置装备摆设与使用 http://www.linuxidc.com/Linux/2017-02/141088.htm
本文永远更新链接地址:http://www.linuxidc.com/Linux/2017-06/145114.htm
编程之家PHP培训学院每天发布《Linux之Vim配置及使用示例》等实战技能,PHP、MysqL、LINUX、APP、JS,CSS全面培养人才。
总结
以上是编程之家为你收集整理的Linux之Vim配置及使用示例全部内容,希望文章能够帮你解决Linux之Vim配置及使用示例所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。