00-03.kaliLinux-vi粘贴复制功能配置

KaliLinux在xShell的vim中默认是无法复制和粘贴的,需要做如下配置后才能使用:

 

方法一

进入vim命令行模式,输入:

:set mouse=c   #进入Command-line 模式

然后就可以正常粘贴复制了。

 

方法二

在root目录中新建一个名称为.vimrc的配置文件。

root@kali:~# vi .vimrc
-----------------------------------------------------------------------
" Vim config file.
 
 
" Global Settings: {{{
syntax on                           " highlight syntax
filetype plugin indent on           " auto detect file type
 
set nocompatible                    " out of Vi compatible mode
"set number                          " show line number
set numberwidth=3                   " minimal culumns for line numbers
set textwidth=0                     " do not wrap words (insert)
set nowrap                          " do not wrap words (view)
set showcmd                         " show (partial) command in status line
set ruler                           " line and column number of the cursor position
set wildmenu                        " enhanced command completion
set wildmode=list:longest,full      " command completion mode
set laststatus=2                    " always show the status line
set mouse=                         " use mouse in all mode
set foldenable                      " fold lines
set foldmethod=marker               " fold as marker 
set noerrorbells                    " do not use error bell
set novisualbell                    " do not use visual bell
set t_vb=                           " do not use terminal bell
 
set wildignore=.svn,.git,*.swp,*.bak,*~,*.o,*.a
set autowrite                       " auto save before commands like :next and :make
set cursorline
set hidden                          " enable multiple modified buffers
set history=1000                     " record recent used command history
set autoread                        " auto read file that has been changed on disk
set backspace=indent,eol,start      " backspace can delete everything
set completeopt=menuone,longest     " complete options (insert)
set pumheight=10                    " complete popup height
set scrolloff=5                     " minimal number of screen lines to keep beyond the cursor
set autoindent                      " automatically indent new line
set cinoptions=:0,l1,g0,t0,(0,(s    " C kind language indent options
set clipboard+=unnamed              " shared clipboard
set noexpandtab                     " do not use spaces instead of tabs
 
set tabstop=4                       " number of spaces in a tab
set softtabstop=4                   " insert and delete space of <tab>
set shiftwidth=4                    " number of spaces for indent
set expandtab                       " expand tabs into spaces
set incsearch                       " incremental search
set hlsearch                        " highlight search match
set ignorecase                      " do case insensitive matching
set smartcase                       " do not ignore if search pattern has CAPS
set nobackup                        " do not create backup file
"set noswapfile                      " do not create swap file
set backupcopy=yes                  " overwrite the original file
 
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=gb2312,utf-8,gbk,gb18030
set fileformat=unix
 
set background=dark
"colorscheme SolarizedDark_modified 
"colorscheme wombat_modified
" gui settings
if has("gui_running")
    set guioptions-=T " no toolbar
    set guioptions-=r " no right-hand scrollbar
    set guioptions-=R " no right-hand vertically scrollbar
    set guioptions-=l " no left-hand scrollbar
    set guioptions-=L " no left-hand vertically scrollbar
    autocmd GUIEnter * simalt ~x " window width and height
    language messages zh_CN.utf-8 " use chinese messages if has
endif
 
" Restore the last quit position when open file.
autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \     exe "normal g'\"" |
    \ endif
"}}}
 
" Key Bindings: {{{
let mapleader = ","
let maplocalleader = "\\"
 
" map : -> <space>
map <Space> :
 
" move between windows
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
 
" Don't use Ex mode, use Q for formatting
map Q gq
 
"make Y consistent with C and D
nnoremap Y y$
 
" toggle highlight trailing whitespace
nmap <silent> <leader>l :set nolist!<CR>
 
" Ctrl-E to switch between 2 last buffers
nmap <C-E> :b#<CR>
 
" ,e to fast finding files. just type beginning of a name and hit TAB
nmap <leader>e :e **/
 
" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>
 
" ,n to get the next location (compilation errors, grep etc)
nmap <leader>n :cn<CR>
nmap <leader>p :cp<CR>
 
" Ctrl-N to disable search match highlight
nmap <silent> <C-N> :silent noh<CR>
 
" center display after searching
nnoremap n   nzz
nnoremap N   Nzz
nnoremap *   *zz
nnoremap #   #zz
nnoremap g*  g*zz
nnoremap g#  g#z
"}}}
 
" mru
let MRU_Window_Height = 10
nmap <Leader>r :MRU<cr>
 
" taglist
let g:Tlist_WinWidth = 25
let g:Tlist_Use_Right_Window = 0
let g:Tlist_Auto_Update = 1
let g:Tlist_Process_File_Always = 1
let g:Tlist_Exit_OnlyWindow = 1
let g:Tlist_Show_One_File = 1
let g:Tlist_Enable_Fold_Column = 0
let g:Tlist_Auto_Highlight_Tag = 1
let g:Tlist_GainFocus_On_ToggleOpen = 1
nmap <Leader>t :TlistToggle<cr>
 
" nerdtree
let g:NERDTreeWinPos = "right"
let g:NERDTreeWinSize = 30
let g:NERDTreeShowLineNumbers = 1
let g:NERDTreeQuitOnOpen = 1
nmap <Leader>f :NERDTreeToggle<CR>
nmap <Leader>F :NERDTreeFind<CR>
 
"paste
vmap <C-c> "+y
nmap <C-v> "+p
set pastetoggle=<F12>
 
"C,C++ Java Compile and run by F5
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
    exec "w"
    if &filetype == 'c'
        exec "!g++ % -o %<"
        exec "! ./%<"
    elseif &filetype == 'cpp'
        exec "!g++ % -o %<"
        exec "! ./%<"
    elseif &filetype == 'java' 
        exec "!javac %" 
        exec "!java %<"
    elseif &filetype == 'sh'
        :!./%
    endif
endfunc
 
"C,C++ debug
map <F8> :call Rungdb()<CR>
func! Rungdb()
    exec "w"
    exec "!g++ % -g -o %<"
    exec "!gdb ./%<"
endfunc

-----------------------------------------------------------
:wq
-----------------------------------------------------------
root@kali:~#
View Code

至此,用vim打开文件就具有粘贴和复制的功能,并且有高亮和至此,用vim打开文件就具有粘贴和复制的功能,并且有高亮和颜色了。

颜色了。

posted @ 2020-06-02 14:27  小白_china  阅读(2017)  评论(0编辑  收藏  举报