Choosing the second object in a line in vim - vim

When I have a line like the following, I can visual select everything in the first quotes with vi".
if foo == "bar" and bar == "foo":
Is there a way in vim how I can visual select foo instead of bar by also using something like vi?

No faster way, you have to move to the target "foo" then do vi".
the "bar" could be selected when you are at the beginning of the line ( or before the "bar"). because " is not "paired characters".
E.g. when your cursor on and, do a vi", you will select and bar == which is not what you expected.
So you have to move your cursor to the target "foo"
P.S, I have ever asked a question some time ago here, you may want to take a look:
Why ci" and ci(, ci{.... behave differently?

From this gist by Steve Losh (there are other versions):
" Motion for "next/last object". For example, "din(" would go to the next "()" pair
" and delete its contents.
onoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
xnoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
onoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
xnoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
onoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
xnoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
onoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
xnoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
function! s:NextTextObject(motion, dir)
let c = nr2char(getchar())
if c ==# "b"
let c = "("
elseif c ==# "B"
let c = "{"
elseif c ==# "d"
let c = "["
endif
exe "normal! ".a:dir.c."v".a:motion.c
endfunction

I would just do it like f";;vi".

Related

Vim change in N item of line possible? E.g. ci2"

I commonly want to change the second (or third) attribute in a string of HTML:
<div class="Something" data-change="TOBECHANGED">Test</div>
At present, I'm doing f" then ; as needed then ci". I realise I could search and replace but that's not what I'm interested in.
Then it occurred that I should be able to do something like c2i" (Change 2nd In "). This doesn't work - is this possible? If so, what's the correct syntax?
With built-in commands, this is a two-step process: First locate the quotes (e.g. via 3f"), then select them (ci").
But you can make that a single-step via custom text objects. I have the following, with which you can do c2if":
" af{c}, if{c} a / inner [count]'th next {c} text object in the current
" line.
" aF{c}, iF{c} a / inner [count]'th previous {c} text object in the
" current line.
" For example, "dif(" would go to the next "()" pair and
" delete its contents.
" Source: Steve Losh, https://bitbucket.org/sjl/dotfiles/src/tip/vim/.vimrc
function! s:NextTextObject( scope, isBackward )
let l:char = ingo#query#get#Char()
if empty(l:char) | return | endif
let l:save_cursor = getpos('.')
let l:direction = (a:isBackward ? 'F' : 'f')
" Special case for "tag" text object.
let l:findChar = tr(l:char, 't', '>')
let l:nextTextObject = l:direction . l:findChar . 'v' . a:scope . l:char
" To handle [count], we can't just prepend it to the f / F command, as
" depending on the text object, there can be two identical delimiters that
" need to be skipped (e.g. in i", but not in i[). Instead, select each text
" object in turn, and then repeat at the corresponding border.
let l:count = v:count1
while l:count > 1
let l:cursor = getpos('.')
execute 'normal!' l:nextTextObject . "\<Esc>" .
\ (a:isBackward ? 'g`<' . (a:scope ==# 'i' ? "\<Left>" : '') : '')
if l:cursor == getpos('.')
call cursor(l:save_cursor[1:2])
execute "normal! \<C-\>\<C-n>\<Esc>" | " Beep.
return
endif
let l:count -= 1
endwhile
execute 'normal!' l:nextTextObject
if mode() ==# 'n'
call cursor(l:save_cursor[1:2])
execute "normal! \<C-\>\<C-n>\<Esc>" | " Beep.
endif
endfunction
onoremap <silent> af :<C-u>call <SID>NextTextObject('a', 0)<CR>
xnoremap <silent> af :<C-u>call <SID>NextTextObject('a', 0)<CR>
onoremap <silent> if :<C-u>call <SID>NextTextObject('i', 0)<CR>
xnoremap <silent> if :<C-u>call <SID>NextTextObject('i', 0)<CR>
onoremap <silent> aF :<C-u>call <SID>NextTextObject('a', 1)<CR>
xnoremap <silent> aF :<C-u>call <SID>NextTextObject('a', 1)<CR>
onoremap <silent> iF :<C-u>call <SID>NextTextObject('i', 1)<CR>
xnoremap <silent> iF :<C-u>call <SID>NextTextObject('i', 1)<CR>
Note: This requires my ingo-library plugin.

Mapping with v:count in vim

I would like to map <c-c> to copy with some improvements over the well known <c-c> shortcuts. If possible I would also like to use a generic mapping for it. I heard about v:count and I am wondering if a can use it here.
" Copy word under cursor
inoremap <silent> <c-c> <esc>m`viw"+y``a
nnoremap <silent> <c-c> m`viw"+y``
" Copy selection
vnoremap <c-c> "+y
" Copy word under cursor in register [count]
inoremap <silent> 1<c-c> <esc>m`viw"1y``a
inoremap <silent> 2<c-c> <esc>m`viw"2y``a
inoremap <silent> 3<c-c> <esc>m`viw"3y``a
[...]
inoremap <silent> 7<c-c> <esc>m`viw"7y``a
inoremap <silent> 8<c-c> <esc>m`viw"8y``a
inoremap <silent> 9<c-c> <esc>m`viw"9y``a
nnoremap <silent> 1<c-c> m`viw"1y``
nnoremap <silent> 2<c-c> m`viw"2y``
nnoremap <silent> 3<c-c> m`viw"3y``
[...]
nnoremap <silent> 8<c-c> m`viw"8y``
nnoremap <silent> 9<c-c> m`viw"9y``
The question is, can I use something like this and how can I do it ?
nnoremap <silent> <c-c> m`viw"{v:count}y``
Edit:
With your help, I made this but I still have some issues with it. For instance, when I do 3 it will paste the content of the 'e' register 3 times. How to avoid that ?
nnoremap <expr> <C-c> MyYank()
inoremap <expr> <C-c> MyYank()
vnoremap <expr> <C-c> MyYank()
nnoremap <expr> <C-v> MyPaste('n')
" Not using numbered registers because they get rotated due to quote_number
" Instead. A indexed string is used to map <count> to a letter
let s:mapping = 'qwertzuiop'
fu! MyYank(...)
" Get the register to yank in
let l:count = v:count > len(s:mapping) ? 0 : v:count
let l:regs = l:count ? s:mapping[l:count - 1] : '+'
" Action depends on the current mode
let l:currentmode = a:0 > 0 ? a:1 : mode()
if l:currentmode == 'n'
return 'm`viw"' . l:regs . 'y``'
elseif l:currentmode == 'i'
return "\e" . 'm`viw"' . l:regs . 'y``a'
elseif l:currentmode == 'v'
return '"' . l:regs . 'y'
endif
endfu
fu! MyPaste(...)
" Get the register to yank in
let l:count = v:count > len(l:mapping) ? 0 : v:count
let l:regs = l:count ? l:mapping[l:count - 1] : '+'
" Action depends on the current mode
let l:currentmode = a:0 > 0 ? a:1 : mode()
if l:currentmode == 'n'
return '"' . l:regs . 'P'
elseif l:currentmode == 'i'
return "\e" . 'm`viw"' . l:regs . 'y``a'
elseif l:currentmode == 'v'
return '"' . l:regs . 'y'
endif
endfu
You can do that with a :help :map-expr:
" Copy word under cursor in register [count]
nnoremap <expr> <silent> <c-c> 'm`viw"' . (v:count ? v:count : '"') . 'y``'
However, like #FDinoff, I'd ask you to reconsider your approach of yanking to the numbered registers. If you rework your original <C-c> mapping (using :map-expr and v:register), you can already yank into arbitrary registers (by prefixing with "{reg}) and still default to the clipboard. And those :imaps with the count will cause a noticeable delay when entering numbers.

Is there a way to expand a Vim fold automatically when your put your cursor on it?

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

Setting to skip over punctuation when moving forwards and backwards words

When I'm using vim I generally never want to move to a punctuation mark when I press w or b to go forwards or backwards. So I'm wondering if there's a setting or something to change this functionality?
e.g. If I've got some code like
object.method(args)
and my cursor is at the [o] in "object" then I want w to move to the [m] in "method", and another w to move to the [a] in "args". I don't want it to land on the [.] or the [(]. If I've ever wanted to move to a punctuation char I've always used f or F to jump straight to it. I've never personally wanted to move to a punctuation char when I move through words and I just realized this is really bugging me.
I too find that I would like a movement that is more inclusive that w, but not as inclusive as W. In particular, I would like a movement that only considers tokens beginning with alphanumeric characters as significant.
So I came up with the following:
" <SPACE> : forward to next word beginning with alphanumeric char
" <S-SPACE> : backward to prev word beginning with alphanumeric char
" <C-SPACE> : same as above (as <S-SPACE> not available in console Vim
" <BS> : back to prev word ending with alphanumeric char
function! <SID>GotoPattern(pattern, dir) range
let g:_saved_search_reg = #/
let l:flags = "We"
if a:dir == "b"
let l:flags .= "b"
endif
for i in range(v:count1)
call search(a:pattern, l:flags)
endfor
let #/ = g:_saved_search_reg
endfunction
nnoremap <silent> <SPACE> :<C-U>call <SID>GotoPattern('\(^\\|\<\)[A-Za-z0-9_]', 'f')<CR>
vnoremap <silent> <SPACE> :<C-U>let g:_saved_search_reg=#/<CR>gv/\(^\\|\<\)[A-Za-z0-9_]<CR>:<C-U>let #/=g:_saved_search_reg<CR>gv
nnoremap <silent> <S-SPACE> :<C-U>call <SID>GotoPattern('\(^\\|\<\)[A-Za-z0-9_]', 'b')<CR>
vnoremap <silent> <S-SPACE> :<C-U>let g:_saved_search_reg=#/<CR>gv?\(^\\|\<\)[A-Za-z0-9_]<CR>:<C-U>let #/=g:_saved_search_reg<CR>gv
nnoremap <silent> <BS> :call <SID>GotoPattern('[A-Za-z0-9_]\(\>\\|$\)', 'b')<CR>
vnoremap <silent> <BS> :<C-U>let g:_saved_search_reg=#/<CR>gv?[A-Za-z0-9_]\(\>\\|$\)<CR>:<C-U>let #/=g:_saved_search_reg<CR>gv
" Redundant mapping of <C-SPACE> to <S-SPACE> so that
" above mappings are available in console Vim.
"noremap <C-#> <C-B>
if has("gui_running")
map <silent> <C-Space> <S-SPACE>
else
if has("unix")
map <Nul> <S-SPACE>
else
map <C-#> <S-SPACE>
endif
endif
I have had this for a long time now, and I find that I use <SPACE>/<C-SPACE> movements so much more than w and W; it just seems more useful when coding. You can, of course, map the commands to whatever keys you find useful or more appropriate.
Even running the risk of creating a script for something that's built-in (like
I did last time), here is a little function that may help accomplishing
this.
function! JumpToNextWord()
normal w
while strpart(getline('.'), col('.')-1, 1) !~ '\w'
normal w
endwhile
endfunction
Basically, what it does is executing the standard w and repeating it
if the character under the cursor is not in a word character (feel free to
change that pattern.
If you add that and a little map in your .vimrc:
nnoremap <silent> ,w :call JumpToNextWord()<CR>
It should work.

Turn off the highlight feature in the Limp

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.

Resources