I'd like to have to same remap to open and close my terminal.
Here is my remap to open it : nnoremap <C-s> :bel vert term<CR>
What I want is that when my terminal is already open, if I type <C-s> again, it execute exit<CR>
I already tried a function that I found here : Toggle function in vim
let s:enable = 0
function! ToggleEasyMode()
if s:enable
nnoremap <C-s> exit<CR>
let s:enable = 0
else
nnoremap <C-s> :bel vert term<CR>
let s:enable = 0
endif
endfunction
thanks to #ChristianGibbons
the answer:
nnoremap <C-s> :bel vert term<CR>
tnoremap <C-s> <CR>exit<CR>
Related
I made :wincmd h<CR> shortcut to <leader>h, and mapleader is <Space> to me
but When I do <leader>h, I feel quite long delay to execute this action,
so I searched commands about <leader>h by :map <leader>h and
I found that I have serveral commands start with <Space>h like below
n <Space>hp #<Plug>(GitGutterPreviewHunk)
n <Space>hu #<Plug>(GitGutterUndoHunk)
n <Space>hs #<Plug>(GitGutterStageHunk)
x <Space>hs #<Plug>(GitGutterStageHunk)
n <Space>h * :wincmd h<CR>
I think because of map priority, <Space>h is performed last,
I want to change execution priority <Space>h to first place.
because <Space>h is the best easy way shortcut to me for :windcmd h.
How do I change priority order of map?
==== edit ====
I think vim wait for next character from h,
then How can I eliminate delay for <Space>h?
<nowait> is not working (I don't know why)
remapping for plugin is not working
==== edit2 ==== (it still not work thought adopt first answer)
init.vim
""Source file
source $HOME/.config/nvim/ascii_art.vim
""Plugin-install
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'tweekmonster/gofmt.vim'
Plug 'tpope/vim-fugitive'
Plug 'vim-utils/vim-man'
Plug 'mbbill/undotree'
Plug 'sheerun/vim-polyglot'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'stsewd/fzf-checkout.vim'
Plug 'vuciv/vim-bujo'
Plug 'tpope/vim-dispatch'
Plug 'theprimeagen/vim-be-good', {'do': './install.sh'}
Plug 'vim-airline/vim-airline'
Plug 'gruvbox-community/gruvbox'
Plug 'vifm/vifm.vim'
"Theme
Plug 'colepeters/spacemacs-theme.vim'
Plug 'sainnhe/gruvbox-material'
Plug 'phanviet/vim-monokai-pro'
Plug 'flazz/vim-colorschemes'
Plug 'chriskempson/base16-vim'
" fuzzy find files
Plug 'ctrlpvim/ctrlp.vim'
" git gutter
Plug 'airblade/vim-gitgutter'
Plug 'scrooloose/nerdcommenter'
"NerdTree plugins (NerdTree makes vim too slow, so now it unstalled)
"Plug 'scrooloose/nerdtree'
"Plug 'Xuyuanp/nerdtree-git-plugin'
"Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
"Plug 'ryanoasis/vim-devicons'
Plug 'mattn/emmet-vim'
Plug 'vimwiki/vimwiki' "take note
Plug 'mhinz/vim-startify' "easy way to save and load session
call plug#end()
""General-setting
language en_US
syntax on
set number
set relativenumber
set guicursor=
set relativenumber
set nohlsearch
set hidden
set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4 "tab key spaces, = set sw
set expandtab "instead of tab, insert spaces
set smartindent
set nu
set nowrap
set smartcase
set noswapfile
set undofile
set incsearch
set termguicolors
set scrolloff=8 "Scroll offset
set noshowmode
set cmdheight=2
set updatetime=50
set shortmess+=c
set cursorline
set hlsearch "highlight searched words
"NOTE :eol is end of the line
set listchars=eol:↲,tab:→\ ,trail:~,extends:>,precedes:<,space:␣
set nolist "set list => $ is end of the line
"Fold setting: when auto save and load fold
set foldcolumn=2
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent! loadview
highlight ColorColumn ctermbg=0 guibg=lightgrey
""Color Theme
colorscheme gruvbox
"cursorline termguicolors
set background=dark
let g:gruvbox_contrast='soft'
let loaded_matchparen = 1
let mapleader = " "
""Status-line
set statusline=
set statusline+=%#IncSearch#
set statusline+=\ %y
set statusline+=\ %r
set statusline+=%#CursorLineNr#
set statusline+=\ %F
set statusline+=%= "Right side settings
set statusline+=%#Search#
set statusline+=\ %l/%L
set statusline+=\ [%c]
""Key-bindings
nnoremap <leader>gc :GCheckout<CR>
nnoremap <leader>ghw :h <C-R>=expand("<cword>")<CR><CR>
nnoremap <leader>prw :CocSearch <C-R>=expand("<cword>")<CR><CR>
nnoremap <leader>pw :Rg <C-R>=expand("<cword>")<CR><CR>
nnoremap <nowait> <leader>j :wincmd j<CR>
nnoremap <nowait> <leader>k :wincmd k<CR>
nnoremap <nowait> <leader>l :wincmd l<CR>
"bug report:: :wincmd h is mapped with below mapping,
"> but can not use shortcuts for GigGutterPreviewHunk, GitGutterUndoHunk, GitGutterStageHunk
autocmd filetype * nnoremap <nowait> <buffer> <leader>h :wincmd h<CR>
"nnoremap <nowait> <leader>h :wincmd h<CR>
nnoremap <leader>u :UndotreeShow<CR>
"nnoremap <leader>pv :wincmd v<bar> :Ex <bar> :vertical resize 30<CR>
nnoremap <leader>pv :call ToggleNetrw() <bar> :vertical resize 30<CR>
nnoremap <Leader>ps :Rg<SPACE>
nnoremap <C-p> :GFiles<CR>
nnoremap <Leader>pf :Files<CR>
nnoremap <Leader><CR> :<c-u>call <sid>Goto_definition() <CR>
nnoremap <F4> :so ~/.config/nvim/init.vim<CR>
nnoremap <Left> :vertical resize -2<CR>
nnoremap <Right> :vertical resize +2<CR>
nnoremap <Up> :resize +2<CR>
nnoremap <Down> :resize -2<CR>
nnoremap <Leader>rp :resize 100<CR>
nnoremap <Leader>ee oif err != nil {<CR>log.Fatalf("%+v\n", err)<CR>}<CR><esc>kkI<esc>
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
vnoremap X "_d
"built-in mapping disable
nnoremap Q <Nop>
" vim TODO
nmap <Leader>tu <Plug>BujoChecknormal
nmap <Leader>th <Plug>BujoAddnormal
let g:bujo#todo_file_path = $HOME . "/.cache/bujo"
" GoTo code navigation.
nmap <leader>gd <Plug>(coc-definition)
nmap <leader>gy <Plug>(coc-type-definition)
nmap <leader>gi <Plug>(coc-implementation)
nmap <leader>gr <Plug>(coc-references)
nmap <leader>rr <Plug>(coc-rename)
nmap <leader>g[ <Plug>(coc-diagnostic-prev)
nmap <leader>g] <Plug>(coc-diagnostic-next)
nmap <silent> <leader>gp <Plug>(coc-diagnostic-prev-error)
nmap <silent> <leader>gn <Plug>(coc-diagnostic-next-error)
nnoremap <leader>cr :CocRestart
nnoremap <silent> K :call <SID>show_documentation()<CR>
"quickly enter new line in normal mode
nnoremap <Leader>o o<Esc>
nmap ghs <Plug>(GitGutterStageHunk)
xmap ghs <Plug>(GitGutterStageHunk)
nmap ghu <Plug>(GitGutterUndoHunk)
nmap ghp <Plug>(GitGutterPreviewHunk)
"Emmet key
let g:user_emmet_mode="n"
let g:user_emmet_leader_key="," "default leader_key is <c-y> with trailing ,(comma)
" coc config
let g:coc_global_extensions = [
\ 'coc-snippets',
\ 'coc-pairs',
\ 'coc-tsserver',
\ 'coc-eslint',
\ 'coc-prettier',
\ 'coc-json',
\ 'coc-marketplace',
\ ]
"coc snippet
" Use <C-l> for trigger snippet expand.
imap <C-l> <Plug>(coc-snippets-expand)
" Use <C-j> for select text for visual placeholder of snippet.
vmap <C-j> <Plug>(coc-snippets-select)
" Use <C-j> for jump to next placeholder, it's default of coc.nvim
let g:coc_snippet_next = '<c-j>'
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim
let g:coc_snippet_prev = '<c-k>'
" Use <C-j> for both expand and jump (make expand higher priority.)
imap <C-j> <Plug>(coc-snippets-expand-jump)
inoremap jk <ESC>
vmap ++ <plug>NERDCommenterToggle
nmap ++ <plug>NERDCommenterToggle
let g:NERDTreeIgnore = ['^node_modules$']
" ctrlp
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
" Highlight currently open buffer in NERDTree
autocmd BufEnter * call SyncTree()
" Remap for rename current word
nmap <F2> <Plug>(coc-rename)
"Functions
"show documetation function
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
"sync open file with NERDTree, Check if NERDTree is open or active
function! IsNERDTreeOpen()
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction
" Call NERDTreeFind iff NERDTree is active, current window contains a modifiable, file, and we're not in vimdiff
function! SyncTree()
if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
NERDTreeFind
wincmd p
endif
endfunction
" autocomplete functions for neoclide/coc.nvim
"---------------------------------------------------------------------------
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-#> coc#refresh()
endif
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
" <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`.
if exists('*complete_info')
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif
"open implementation to the right split view(custom function)
"buggy: If you quit after invoke this function, this function will not work(it will quit your only window)
let s:first_open=1
function! s:Goto_definition() abort
if s:first_open
rightbelow vs "same as :vertical split and :wincmd l
normal K
wincmd h
let s:first_open=0
else
wincmd l "If right split window exists then quit
q
rightbelow vs
normal K
wincmd h
endif
endfunction
"---------------------------------------------------------------------------
"" netrw settings
let g:netrw_liststyle=3 "Tree style
let g:netrw_banner = 0 "Remove banner
let g:netrw_browse_split = 4 "Open file in previous window
let g:netrw_altv = 1 "Open vertical split window to the right side
let g:netrw_preview=1 "Preview in right side
set nocompatible "Limit search for your project
set path+=** "Search all subdirectories with recursively
set wildmenu "Show multifiles on one line when you :find
"Root directory:make current directory to root directory
nnoremap <leader>` :Ntree<CR>
let g:NetrwIsOpen=0
function! ToggleNetrw()
if g:NetrwIsOpen
let i = bufnr("$")
while (i >= 1)
if (getbufvar(i, "&filetype") == "netrw")
silent exe "bwipeout " . i
endif
let i-=1
endwhile
let g:NetrwIsOpen=0
else
let g:NetrwIsOpen=1
silent Lexplore
endif
endfunction
let g:netrw_list_hide= netrw_gitignore#Hide()
"=================Unorganized settings==================
"jsx comment
let g:NERDCustomDelimiters={
\ 'javascript': { 'left': '//', 'right': '', 'leftAlt': '{/*', 'rightAlt': '*/}' },
\}
"vimwiki setup
"let g:vimwiki_list = [{'path': '~/vimwiki/',
"\ 'syntax': 'markdown', 'ext': '.md'}]
=== edit for Result (now working) ===
for :map <leader>h now show like this picture
what I did
add 4 snippets from answer
:PlugUpdate => I was out of date.
remove <nowait>
:echo hasmapto('<Plug>(GitGutterStageHunk)', 'n') output 1
when upto 2 step, it didn't work, but after remove nowait it works
something interfereing commands, but I don't know exact reason.
The mappings that include <Leader>h as a prefix will cause this interference. Vim will wait for a timeout or additional keypress before executing your <Leader>h mapping, since it wants to check whether you meant to press one of the longer mappings...
The easiest way to fix this is set alternate mappings for the vim-gitgutter commands. If you set up different mappings for those in your vimrc, vim-gitgutter itself will not create its mappings which are causing the interference.
The vim-gitgutter README suggests using g as an alternative prefix for these:
To set your own mappings for these, for example if you prefer g-based maps:
nmap ghs <Plug>(GitGutterStageHunk)
nmap ghu <Plug>(GitGutterUndoHunk)
So just go ahead and create mappings for the four keybindings that are breaking your <Leader>h. Add these four lines to your vimrc:
nmap ghs <Plug>(GitGutterStageHunk)
xmap ghs <Plug>(GitGutterStageHunk)
nmap ghu <Plug>(GitGutterUndoHunk)
nmap ghp <Plug>(GitGutterPreviewHunk)
The xmap (for staging in Visual mode) is technically not required, you could keep using <Leader>hs there without interference... But on the other hand you might want to keep those consistent between Normal and Visual mode, so I'd recommend remapping that one too.
The reason why <noway> doesn't work to fix this is that <nowait> only works on <buffer>-local mappings, when they shadow global mappings. It doesn't work when all your mappings are global. (In that case, Vim prefers to force you to resolve the conflicts, rather than make then longest mappings always unaccessible.)
I would like to map <c-h> to do an easy "replace" in the active buffer
For now I have something like this:
" <c-h> Replacement
noremap <c-h> :%s/<c-R><c-W>//g<left><left>
inoremap <c-h> <esc>:%s/<c-R><c-W>//g<left><left>
vnoremap <c-h> gv:%s/<c-R><c-W>//g<left><left>
The problems are:
The selection is not properly escaped
For the visual mode I do not paste the selection, juste the word below the cursor
Is there anyway to do something like:
inoremap <c-h> <esc>:%s/\=escapechars(<c-R><c-W>)}//g<left><left>
I have this function:
function! GetVisualSelection()
let old_reg = #v
normal! gv"vy
let raw_search = #v
let #v = old_reg
return substitute(escape(raw_search, '\/.*$^~[]'), "\n", '\\n', "g")
endfunction
which you could use like this:
xnoremap <c-h> :<C-u>%s/<C-r>=GetVisualSelection()<CR>//g<left><left>
The "escaping" part could be extracted into its own function:
function! Escape(stuff)
return substitute(escape(a:stuff, '\/.*$^~[]'), "\n", '\\n', "g")
endfunction
which you could use like this:
nnoremap <c-h> :<C-u>%s/<C-r>=Escape(expand('<cword>'))<CR>//g<left><left>
inoremap <c-h> <esc>:%s/<C-r>=Escape(expand('<cword>'))<CR>//g<left><left>
Can you have Vim expand a fold automatically when the cursor touches it?
See the foldopen option. It controls which groups of commands will lead to
opening a fold if the cursor is moved into a closed fold.
Note that vertical movements do not open a closed fold, though. Moreover,
there is no setting in foldopen to enable this behavior. When hor item is
set in foldopen option, to open a fold one can use h, l or other
horizontal movement commands. In case if it is crucial to automatically open
a fold on any cursor movement that touches it, one can approach this problem
by remapping some subset of vertical movement commands like it is shown below.
nnoremap <silent> j :<c-u>call MoveUpDown('j', +1, 1)<cr>
nnoremap <silent> k :<c-u>call MoveUpDown('k', -1, 1)<cr>
nnoremap <silent> gj :<c-u>call MoveUpDown('gj', +1, 1)<cr>
nnoremap <silent> gk :<c-u>call MoveUpDown('gk', -1, 1)<cr>
nnoremap <silent> <c-d> :<c-u>call MoveUpDown("\<lt>c-d>", +1, '&l:scroll')<cr>
nnoremap <silent> <c-u> :<c-u>call MoveUpDown("\<lt>c-u>", -1, '&l:scroll')<cr>
nnoremap <silent> <c-f> :<c-u>call MoveUpDown("\<lt>c-f>", +1, 'winheight("%")')<cr>
nnoremap <silent> <c-b> :<c-u>call MoveUpDown("\<lt>c-b>", -1, 'winheight("%")')<cr>
function! MoveUpDown(cmd, dir, ndef)
let n = v:count == 0 ? eval(a:ndef) : v:count
let l = line('.') + a:dir * n
silent! execute l . 'foldopen!'
execute 'norm! ' . n . a:cmd
endfunction
An inferior, but a bit thriftier solution would be to open a fold on every
cursor movement.
autocmd CursorMoved,CursorMovedI * silent! foldopen
Unfortunately, this solution is not general one. After the fold under the
cursor is opened, the cursor is positioned on the first line of that fold. If
this behavior is undesirable, one can follow the vertical direction of
a movement, and place the cursor on the last line of the fold when the cursor
is moving bottom-up.
autocmd CursorMoved,CursorMovedI * call OnCursorMove()
function! OnCursorMove()
let l = line('.')
silent! foldopen
if exists('b:last_line') && l < b:last_line
norm! ]z
endif
let b:last_line = l
endfunction
However, a fold will not be opened if the movement jumps over the fold. For
example, 2j on the line just above a fold will put the cursor on the line
just after that fold, not the second line in it.
set foldopen=all
seems to do what you want. You may also make an autocommand for cursor movement:
au CursorMoved * call AutoOpen()
calling a function like:
function! AutoOpen()
if foldclosed(".") == line(".")
call feedkeys("zo")
endif
endfunction
If you want this to also work in insert mode, use:
au CursorMoved,CursorMovedI * call AutoOpen()
:help fdo and possibly :help fcl may help you. I have this line in my .vimrc:
set foldopen=block,hor,insert,jump,mark,percent,quickfix,search,tag,undo
I am using the Limp in my VIM. But there is a problem, when the cursor move to a "(" or ")", it would highlight a block of code in this pair.I can not see the code clearly. Is there any way to turn off or delete this feature?
Best Regards,
I'm also using Limp but I have modified it somewhat to work better for my tastes.
Inside the main limp folder there is a vim subfolder, open the file limp.vim and at the end you can see several runtime commands, just comment out the one that loads the highlight.vim file:
"runtime ftplugin/lisp/limp/highlight.vim
I also like to disable the autoclose.vim plugin, I find it very annoying.
"runtime ftplugin/lisp/limp/autoclose.vim
Then, open the file mode.vim and around line number 58 you can see the function call to initialize the highlighting mode; comment it out:
"call LimpHighlight_start()
then around line number 68, under the function LimpMode_stop() you will also need to comment the call to stop the highlightning.
"call LimpHighlight_stop()
Of course, if you also disabled the autoclose.vim plugin you'll also have to comment the calls to start/stop it.
Annoying colors
If the colors that Limp sets up out of the box annoys you as they did with me, you can disable that and continue using your default colorscheme; around line number 30:
"set t_Co=256
"if !exists("g:colors_name")
"colorscheme desertEx
"endif
And change the highlight groups to match your colorscheme (use :high to quickly see a list of color combinations). For example, I use the "desertEx" colorscheme and changed this two lines to match it:
hi BracketsBlock ctermbg=235 guibg=grey22
hi StatusLine ctermbg=black ctermfg=160
Other options
I didn't like the set of options that Limp sets, especially the old Vi Lisp indentation. I also dislike the folding so I disabled that too. My current set of options look like this:
syntax on
setlocal nocompatible nocursorline
setlocal lisp syntax=lisp
setlocal ls=2 bs=2 et sw=2 ts=2 "tw=0
setlocal statusline=%<%f\ \(%{LimpBridge_connection_status()}\)\ %h%m%r%=%-14.(%l,%c%V%)\ %P
"setlocal iskeyword=&,*,+,45,/,48-57,:,<,=,>,#,A-Z,a-z,_
"setlocal cpoptions=-mp
"setlocal foldmethod=marker foldmarker=(,) foldminlines=1
setlocal foldcolumn=0
set lispwords+=defgeneric,block,catch,with-gensyms
"-----------
"Taken from the bundled lisp.vim file in VIM
"(/usr/share/vim/vim72/ftplugin/lisp.vim)
setl comments=:;
setl define=^\\s*(def\\k*
setl formatoptions-=t
setl iskeyword+=+,-,*,/,%,<,=,>,:,$,?,!,#-#,94
setl comments^=:;;;,:;;,sr:#\|,mb:\|,ex:\|#
setl formatoptions+=croql
"-----------
" This allows gf and :find to work. Fix path to your needs
setlocal suffixesadd=.lisp,.cl path+=/home/gajon/Lisp/**
Notice I disabled the tw=0, modified the statusline, disabled folding, copied the options that come bundled with Vim (they are a lot better), added some symbols to lispwords, and added a missing dot to suffixesadd (cl extension was missing a dot).
Disabling the transposing of sexps.
Limp binds they keys { and } to functions that transpose the current sexp with the previous/next sexp. But they don't work reliably and I think they are unnecessary when you can just as easily use dab and p at the proper place. Besides the default Vim {} bindings are quite useful to move to other top-level forms.
In file keys.vim:
"nmap <buffer> { <Plug>SexpMoveBack
"nmap <buffer> } <Plug>SexpMoveForward
Bug when connecting to a running REPL
There's a bug that prevents Limp from reconnecting to an already running REPL. In file bridge.vim inside the vim subfolder, around line number 13:
let cmd = s:Limp_location . "/bin/lisp.sh ".core_opt." -s ".styfile." -b ".name
A space was missing between ".core_opt." and -s.
Additional Goodies!
You should be able to figure out how to use these new mappings.
In file bridge.vim add the following lines after line number 265:
nnoremap <silent> <buffer> <Plug>EvalUndefine :call LimpBridge_send_to_lisp("(fmakunbound '".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>EvalAddWord :let &lispwords.=',' . expand("<cword>")<cr>
nnoremap <silent> <buffer> <Plug>DebugTrace :call LimpBridge_send_to_lisp("(trace ".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>DebugUnTrace :call LimpBridge_send_to_lisp("(untrace ".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>DebugInspectObject :call LimpBridge_inspect_expression()<CR>
nnoremap <silent> <buffer> <Plug>DebugInspectLast :call LimpBridge_send_to_lisp("(inspect *)")<CR>
nnoremap <silent> <buffer> <Plug>DebugDisassemble :call LimpBridge_send_to_lisp("(disassemble #'".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>DebugMacroExpand :call LimpBridge_macroexpand_current_form( "macroexpand" )<CR>
nnoremap <silent> <buffer> <Plug>DebugMacroExpand1 :call LimpBridge_macroexpand_current_form( "macroexpand-1" )<CR>
nnoremap <silent> <buffer> <Plug>ProfileSet :call LimpBridge_send_to_lisp("(sb-profile:profile ".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>ProfileUnSet :call LimpBridge_send_to_lisp("(sb-profile:unprofile ".expand("<cword>").")")<CR>
nnoremap <silent> <buffer> <Plug>ProfileShow :call LimpBridge_send_to_lisp("(sb-profile:profile)")<CR>
nnoremap <silent> <buffer> <Plug>ProfileUnSetAll :call LimpBridge_send_to_lisp("(sb-profile:unprofile)")<CR>
nnoremap <silent> <buffer> <Plug>ProfileReport :call LimpBridge_send_to_lisp("(sb-profile:report)")<CR>
nnoremap <silent> <buffer> <Plug>ProfileReset :call LimpBridge_send_to_lisp("(sb-profile:reset)")<CR>
And at the end add these two functions:
function! LimpBridge_inspect_expression()
let whatwhat = input("Inspect: ")
call LimpBridge_send_to_lisp( "(inspect " . whatwhat . ")" )
endfun
function! LimpBridge_macroexpand_current_form(command)
" save position
let pos = LimpBridge_get_pos()
" find & yank current s-exp
normal! [(
let sexp = LimpBridge_yank( "%" )
call LimpBridge_send_to_lisp( "(" . a:command . " '" . sexp . ")" )
call LimpBridge_goto_pos( pos )
endfunction
Then in file keys.vim add the following mappings:
" Undefine: Undefine a function or macro.
nmap <buffer> <LocalLeader>eu <Plug>EvalUndefine
" Add Word: Append word to 'lispwords' option
nmap <buffer> <LocalLeader>ea <Plug>EvalAddWord
" Trace: Set tracing for function.
" Untrace: Remove tracing for a function.
nmap <buffer> <LocalLeader>dt <Plug>DebugTrace
nmap <buffer> <LocalLeader>du <Plug>DebugUnTrace
" Inspect: Inspect object
" InspectPrev: Inspect last value evaled.
nmap <buffer> <LocalLeader>di <Plug>DebugInspectObject
nmap <buffer> <LocalLeader>dI <Plug>DebugInspectLast
" Disassemble:
nmap <buffer> <LocalLeader>dd <Plug>DebugDisassemble
" Macroexpand:
" Macroexpand1:
nmap <buffer> <LocalLeader>ma <Plug>DebugMacroExpand
nmap <buffer> <LocalLeader>m1 <Plug>DebugMacroExpand1
" Profile: Set profiling.
" Unprofile: Remove profiling.
nmap <buffer> <LocalLeader>pr <Plug>ProfileSet
nmap <buffer> <LocalLeader>pu <Plug>ProfileUnSet
" Show Profiling: Show profiling.
" Unprofile All: Remove all profiling.
nmap <buffer> <LocalLeader>pp <Plug>ProfileShow
nmap <buffer> <LocalLeader>pa <Plug>ProfileUnSetAll
" Profile Report: Show report.
" Profile Reset: Reset profile data.
nmap <buffer> <LocalLeader>ps <Plug>ProfileReport
nmap <buffer> <LocalLeader>p- <Plug>ProfileReset
" Sexp Close Open Parenthesis:
nmap <buffer> <LocalLeader>cp <Plug>SexpCloseParenthesis
imap <buffer> <C-X>0 <C-O><LocalLeader>cp
Then in file sexp.vim add this mapping:
" Sexp Close Open Parenthesis:
nnoremap <silent> <buffer> <Plug>SexpCloseParenthesis :call SlimvCloseForm()<CR>
and these two functions:
"-------------------------------------------------------------------
" Close open parenthesis
" Taken from the Slimv plugin by Tamas Kovacs. Released in the
" public domain by the original author.
"-------------------------------------------------------------------
" Count the opening and closing parens or brackets to determine if they match
function! s:GetParenCount( lines )
let paren = 0
let inside_string = 0
let i = 0
while i < len( a:lines )
let inside_comment = 0
let j = 0
while j < len( a:lines[i] )
if inside_string
" We are inside a string, skip parens, wait for closing '"'
if a:lines[i][j] == '"'
let inside_string = 0
endif
elseif inside_comment
" We are inside a comment, skip parens, wait for end of line
else
" We are outside of strings and comments, now we shall count parens
if a:lines[i][j] == '"'
let inside_string = 1
endif
if a:lines[i][j] == ';'
let inside_comment = 1
endif
if a:lines[i][j] == '(' || a:lines[i][j] == '['
let paren = paren + 1
endif
if a:lines[i][j] == ')' || a:lines[i][j] == ']'
let paren = paren - 1
if paren < 0
" Oops, too many closing parens in the middle
return paren
endif
endif
endif
let j = j + 1
endwhile
let i = i + 1
endwhile
return paren
endfunction
" Close current top level form by adding the missing parens
function! SlimvCloseForm()
let l2 = line( '.' )
normal 99[(
let l1 = line( '.' )
let form = []
let l = l1
while l <= l2
call add( form, getline( l ) )
let l = l + 1
endwhile
let paren = s:GetParenCount( form )
if paren > 0
" Add missing parens
let lastline = getline( l2 )
while paren > 0
let lastline = lastline . ')'
let paren = paren - 1
endwhile
call setline( l2, lastline )
endif
normal %
endfunction
Hope this helps you better use Limp.
Problem: to move upwards in Vim's Taglist by "t"
The movement keys DHTN work in Vim when I am not in TagList.
I have the following in my .vimrc
no h j
no t k
no n l
no s :
no S :
no j d
no J D
no l n
no L N
no - $
no _ ^
no N
no ; z
no T L
no P P
no p p
How can you enable the movement key "t" also in TagList?
The problem is that Tag List has defined very specific action to these keys, so rebinding them has moved functionality on top of it and can not be used to shift responsibility. There might be another way, but you can edit taglist.vim at line :1560 and :1562
nnoremap <buffer> <silent> t
nnoremap <buffer> <silent> <C-t>
change 't' to the letter you want, maybe 'l'. You will also find all the other key bindings in this area. While not needed or affected by these changes, you can also update the help message if you change other bindings starting at line :535
The problem can be solved by adding the following to your .vimrc
if v:version >= 700
nnoremap <buffer> <silent> t
\
nnoremap <buffer> <silent> <C-t>
\
endif
Response to Great's question:
I remaped the key unsuccessfully by adding the following to my .vimrc
if v:version >= 700
nnoremap <buffer> <silent> l
\ :call <SID>Tlist_Window_Jump_To_Tag('checktab')<CR>
nnoremap <buffer> <silent> <C-l>
\ :call <SID>Tlist_Window_Jump_To_Tag('newtab')<CR>
endif
How would you do the remap?