一些命令

本文介绍了Vim编辑器的个性化配置方法,包括设置背景、行号、Tab宽度等,并提供了快速重新加载及编辑.vimrc文件的方法。此外,还实现了代码编译运行和格式化的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

vim:


myrc

“updata 10_4_29

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function! MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '/<cmd'
let cmd = '""' . $VIMRUNTIME . '/diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '/diff"'
endif
else
let cmd = $VIMRUNTIME . '/diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction

"***************************MYVIMRC*************************
"-----------------------------EDIT--------------------------
"设置背景
colorscheme darkblue
"显示行号
se nu
"tab 键为4
se ts=4
" Set mapleader
let mapleader = ","
"Fast reloading of .vimrc
map <silent> <leader>ss :source $vim/_vimrc<cr>

"Fast editing of .vimrc
map <silent> <leader>ee :tabnew<cr>:e $vim/_vimrc<cr>
"when .vimrc is edited,reload it
autocmd! bufwritepost .vimrc :source $vim/_vimrc

"设置搜索高亮,边写边搜
set hls is
"去掉工具栏
set go-=T
"去掉菜单栏
set go-=m
" 与windows共享剪贴板
set clipboard+=unnamed
" 启动的时候不显示那个援助索马里儿童的提示
set shortmess=atI
"设置字体
set guifont=Consolas:h11

"-----------------------IDE-----------------------
map <F5> :call CompileRun()<CR>
"设置代码格式化快捷键F3
map <F3> :call FormartSrc()<CR>
"定义CompileRun函数,用来调用进行编译和运行
func! CompileRun()
exec "w"
"C程序
if &filetype == 'c'
exec "!del %<.exe"
exec "!gcc % -o %<.exe"
exec "!%<.exe"
elseif &filetype == 'cpp'
exec "!del %<.exe"
exec "!g++ % -o %<.exe"
exec "!%<.exe"
"Java程序
elseif &filetype == 'java'
exec "!del %<.class"
exec "!javac %"
exec "!java %<"
endif
endfunc
"结束定义CompileRun
"
""定义FormartSrc()
func! FormartSrc()
exec "w"
"C程序,Perl程序,Python程序
if &filetype == 'c'
exec "!astyle --style=gnu --suffix=none %"
exec "e! %"
elseif &filetype == 'cpp'
exec "!astyle --style=gnu --suffix=none %"
exec "e! %"
elseif &filetype == 'perl'
exec "!astyle --style=gnu --suffix=none %"
exec "e! %"
elseif &filetype == 'py'
exec "!astyle --style=gnu --suffix=none %"
exec "e! %"
"Java程序
elseif &filetype == 'java'
exec "!astyle --style=java --suffix=none %"
exec "e! %"
elseif &filetype == 'jsp'
exec "!astyle --style=gnu --suffix=none %"
exec "e! %"
elseif &filetype == 'xml'
exec "!astyle --style=gnu --suffix=none %"
exec "e! %"
elseif &filetype == 'html'
exec "!astyle --style=gnu --suffix=none %"
exec "e! %"

elseif &filetype == 'htm'
exec "!astyle --style=gnu --suffix=none %"
exec "e! %"

endif
endfunc
"结束定义FormartSrc


:noh 去除搜索后高亮

%s/x/y/g 把全文中的x 替换成y


win+r/cmd:

convert x: /fs ntfs---convert fat32 to ntfs;

copy con 1.txt 然后回车,在下面输入文字,要退出时,按CTRL+Z,再回车。

services.msc---本地服务设置

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值