aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-06-23 16:07:22 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-06-23 16:09:53 +1200
commit223e2dd68131ad6937b43bb147110fd25961a58a (patch)
tree5c82a21191ef0e9d14f0f07802da3169c86e8224
parentBump VERSION (diff)
downloadvim-fixed-join-223e2dd68131ad6937b43bb147110fd25961a58a.tar.gz
vim-fixed-join-223e2dd68131ad6937b43bb147110fd25961a58a.zip
Silently cap join end to last line of buffer
This avoids raising an error if the user requests joining lines beyond the last line of the buffer.
-rw-r--r--plugin/fixed_join.vim9
1 files changed, 8 insertions, 1 deletions
diff --git a/plugin/fixed_join.vim b/plugin/fixed_join.vim
index ae0e086..f64b650 100644
--- a/plugin/fixed_join.vim
+++ b/plugin/fixed_join.vim
@@ -20,8 +20,15 @@ function! s:FixedJoin()
let l:cursor_line = line('.')
let l:cursor_col = col('.')
+ " Find last line of join; silently cap it to last buffer line
+ let l:join_line = l:cursor_line + v:count1
+ let l:last_line = line('$')
+ if l:join_line > l:last_line
+ let l:join_line = l:last_line
+ endif
+
" Build and execute join command
- let l:command = '.,+' . v:count1 . 'join'
+ let l:command = '.,' . l:join_line . 'join'
execute l:command
" Return the cursor to the saved position (Vim 6.0 fallback)