2013-07-08 6 views
3

настоящее время у меня мой .vimrc настроен так, чтоЕсть ли способ изменить раскладку VIM Surround?

  • 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 
+3

Переопределение основных операторов, таких как 'sdc', не очень яркая идея. Вы должны использовать пользовательский '' eiher неявно, как вы это делали с ', 3' и друзьями или явно после прочтения': help mapleader'. – romainl

ответ

5

Если вы посмотрите на исходный код для объемного плагина вы увидите следующий блок:

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 

Как вы можете видеть, вы можете предотвратить плагин от картографирования чего-либо, добавив следующее к вашему :

let g:surround_no_mappings = 1 

Затем вы можете добавить свои собственные сопоставления для функций, определенных в этих блоках.

+0

Спасибо Рэнди. Поэтому я просто ввел 'let g: surround_no_mappings = 1', и если бы я хотел добавить свое собственное сопоставление для команды' Csurround', было бы что-то вроде 'nmap fcs Csurround' в моем' .vimrc' делать трюк? –

+0

Это идея. Я не могу проверить это сейчас, чтобы быть на 100% уверенным, но обычно это должно работать. –

+0

Да, это сработало. Благодарю. –

Смежные вопросы