gpt4 book ai didi

vim - 有没有办法改变 VIM Surround 的键盘映射?

转载 作者:行者123 更新时间:2023-12-01 10:52:23 26 4
gpt4 key购买 nike

我目前设置了 .vimrc

  • s 保存我的文件
  • d 删除在可视模式下突出显示的任何文本
  • c 将注释光标所在的任何行(或任何一组突出显示的行)

很明显,这会阻止我使用 Surround 的默认命令。有没有办法让我在 .vimrc 中创建自己的命令来替换 Surround 的默认命令?

这是我的.vimrc

set nocompatible

filetype off " required!

set rtp+=~/.vim/bundle/vundle
call vundle#rc()

" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'

" My Bundles here:
"
" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'jistr/vim-nerdtree-tabs'
" Bundle 'tpope/vim-haml'
Bundle 'ap/vim-css-color'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle "pangloss/vim-javascript"
" vim-scripts repos
Bundle 'surround.vim'
Bundle 'delimitMate.vim'
Bundle 'hail2u/vim-css3-syntax'
" Bundle 'AutoComplPop'
" Bundle 'ervandew/supertab'
Bundle 'snipMate'
Bundle 'tComment'
" Bundle 'mru.vim'
Bundle 'scrooloose/nerdtree'
Bundle 'matchit.zip'
Bundle 'Vimball'
Bundle 'ScrollColors'
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
Bundle 'git://git.wincent.com/command-t.git'

" Shortcuts

" Basic pair completion
" inoremap { {}<Left>
" inoremap {<CR> {<CR>}<Esc>O
" inoremap {{ {
" inoremap {} {}

" inoremap : :;<Left>
"inoremap :<CR> :;
"noremap :: :;<Left>
"inoremap :; :;

" Create new buffers vertically or horizontally
nnoremap ,v <C-w>v
nnoremap ,h <C-w>s

" Toggle between the buffers
nnoremap ,, <C-w>w

" Increase or decrease buffer size
noremap <C-Up> <C-W>+
noremap <C-Down> <C-W>-
noremap <C-Left> <C-W>>
noremap <C-Right> <C-W><


nmap gf <S-g>
nmap f :FufFile <CR>
vmap c gc
nmap c gcc
nmap tt :tabnew <CR>
nmap tc :tabclose <CR>
nmap ml :MRU <CR>
nmap ,n :NERDTree <CR>;
nmap s :w! <CR>
nmap q :q! <CR>
syntax on
set mouse=a "enables mouse

" map <F2> :NERDTreeToggle<CR>;
map <F2> :NERDTreeTabsToggle<CR>;

" Selecting different color schemes
map <silent> ,3 :NEXTCOLOR<cr>
map <silent> ,2 :PREVCOLOR<cr>
map <silent> ,1 :SCROLL<cr>

" Directory Set up

set backup "backs up files
set backupdir=$HOME/.vimbackup
set directory=$HOME/.vimswap
set viewdir=$HOME/.vimviews
"
" silent execute '!mkdir -p $HOME/.vimbackup'
" silent execute '!mkdir -p $HOME/.vimswap'
" silent execute '!mkdir -p $HOME/.vimviews'

" au BufWinLeave * silent! mkview "makes vim save view state
" au BufWinEnter * silent! loadview "makes vim load view state

" Appearance

set columns=60

set guifont=Monaco\ 11

if has("autocmd")
au InsertEnter * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape ibeam"
au InsertLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape block"
au VimLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape ibeam"
endif

" set guicursor=n-v-c:block-Cursor
" set guicursor+=i:ver100-iCursor
" set guicursor+=n-v-c:blinkon0
" set guicursor+=i:blinkwait10

if has("gui_running")
set guioptions=aiA " Disable toolbar, menu bar, scroll bars
colorscheme jellybeans
else
colorscheme desert256
endif " has("gui_running")

set t_Co=256
set tabpagemax=10 "show only 10 tabs
set background=dark

set number

set scrolloff=3 "minimum lines to keep above/below cursor
set foldenable "auto fold code
set foldmethod=manual

" Behaviour
" set nowrap "wrap long lines
set linebreak
:filetype plugin indent on " lets filetype plugins be used

" Treat SCSS files as CSS files
" au BufRead,BufNewFile *.scss set filetype=css

" Close VIM even if NERDTree is the last buffer
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif

" after appending closing delimiter, it indents
let delimitMate_expand_cr=1

" if bufwinnr(1)
" map <kPlus><C-W>+
" map <kMinus><C-W>-
" map <kDivide><c-w><
" map <kMultiply><c-w>>
" endif

set autoindent
set smartindent
set tabstop=2
set shiftwidth=2
set smarttab
set expandtab
set softtabstop=2
set spell

set showmatch "shows matching parens, brackets

set winminheight=0

set go-=T "eliminates tool bar in gVim
set go-=m "eliminates menu bar in gVim
set go-=r "eliminates right scroll bar
set lines=50 "50 lines of text instead of 24

set backspace=2 "makes backspace work like normally it does
:fixdel

set vb t_vb= "prevents vim from beeping when command is bad. instead it flashes screen.

set ruler "shows statusline, displays curor position

set incsearch "vim searches text as you enter it
" set hlsearch "hilights searched items
set ignorecase "case insensitive search
set smartcase "case sensetive when using captials
set wildmenu "shows list instead of completing
set wildmode=list:longest,full "command <TAB> completeiton, lists matches,
set virtualedit=all "lets cursor freely roam anywhere like in command mode

最佳答案

如果您查看环绕声插件的源代码,您会注意到以下 block :

if !exists("g:surround_no_mappings") || ! g:surround_no_mappings
nmap ds <Plug>Dsurround
nmap cs <Plug>Csurround
nmap ys <Plug>Ysurround
nmap yS <Plug>YSurround
nmap yss <Plug>Yssurround
nmap ySs <Plug>YSsurround
nmap ySS <Plug>YSsurround
xmap S <Plug>VSurround
xmap gS <Plug>VgSurround
if !exists("g:surround_no_insert_mappings") || ! g:surround_no_insert_mappings
if !hasmapto("<Plug>Isurround","i") && "" == mapcheck("<C-S>","i")
imap <C-S> <Plug>Isurround
endif
imap <C-G>s <Plug>Isurround
imap <C-G>S <Plug>ISurround
endif
endif

如您所见,您可以通过将以下内容添加到 .vimrc 来阻止插件映射任何内容:

let g:surround_no_mappings = 1

然后您可以为这些 block 中定义的函数添加您自己的映射。

关于vim - 有没有办法改变 VIM Surround 的键盘映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17537182/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com