linux之vim配置及使用示例
2017-06-20 22:11
435 查看
作者:tongqingliu
转载请注明出处:http://blog.csdn.net/qq_22186119/article/details/73521897
- 一般模式
- 插入模式
- 命令行模式
安装vim
切换到主目录:
配置文件,输入:
保存。通过运行
来查看整个初始化过程。
键入
按
键入
按
键入
按
参考:
http://blog.csdn.net/yangjvn/article/details/47206899
转载请注明出处:http://blog.csdn.net/qq_22186119/article/details/73521897
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 <Tab> 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 <Tab>. " Spaces are used in indents with the '>' and '<' commands " and when 'autoindent' is on. To insert a real tab when " 'expandtab' is on, use CTRL-V <Tab>. set smarttab " When on, a <Tab> in front of a line inserts blanks " according to 'shiftwidth'. 'tabstop' is used in other " places. A <BS> 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 <BS>, <Del>, 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 <CR> 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 <Enter> 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 syntax on
保存。通过运行
vim -V
来查看整个初始化过程。
编写C代码
ltq@lab:~/桌面/tmp$ vim main.c
键入
i,输入
#include<stdio.h> void main() { printf("hello c\n"); }
按
esc键,键入
:wq。
ltq@lab:~/桌面/tmp$ gcc main.c ltq@lab:~/桌面/tmp$ ls a.out main.c ltq@lab:~/桌面/tmp$ ./a.out hello c
编写C++代码
ltq@lab:~/桌面/tmp$ vim main.cpp
键入
i,输入
#include<iostream> using namespace std; int main() { cout<<"hello cpp"<<endl; return 0; }
按
esc键,键入
:wq。
ltq@lab:~/桌面/tmp$ g++ main.cpp ltq@lab:~/桌面/tmp$ ls a.out main.c main.cpp ltq@lab:~/桌面/tmp$ ./a.out hello cpp
编写Python代码
ltq@lab:~/桌面/tmp$ vim main.py
键入
i,输入
print("hello python")
按
esc键,键入
:wq。
ltq@lab:~/桌面/tmp$ python main.py hello python
参考:
http://blog.csdn.net/yangjvn/article/details/47206899
相关文章推荐
- linux之vim配置及使用示例
- 【Linux开发技术之工具使用】配置VIM下编程和代码阅读环境
- Linux - vim安装 配置与使用
- Linux - vim安装 配置与使用
- linux平台vim配置+ctags工具使用
- 【Linux开发技术之工具使用】配置VIM下编程和代码阅读环境 - gnuhpc - 博客园
- Linux中vim的使用,网络配置和进程管理
- linux下docker的配置文件daemon.json使用示例
- Linux vim 入门 配置 及 使用初步
- square开源vim,tmux配置在linux上使用
- 打造Linux下属于自己的强大IDE:VIM配置使用手册
- Linux使用快捷键,who命令,rm命令,ps命令,cd,命令kill命令,find命令,grep命令,tar命令(gz、tar、bz2),用户管理,vim配置的一部分,相关命令
- Eclipse中使用Hadoop伪分布模式开发配置及简单程序示例(Linux下)
- 【Linux开发技术之工具使用】配置VIM下编程和代码阅读环境
- Linux ifconfig命令详解和使用示例(Linux网络参数配置和查看)
- linux vim编辑器配置及使用经验
- linux vim编辑器配置及使用经验
- linux-使用命令安装gcc/g++, gdb, vim :配置yum
- docker深入2-linux下的配置文件daemon.json使用示例
- Linux(Ubuntu)使用vundle管理vim-go及mapping配置说明