On 2021-04-16 09:42, Julius Hamilton wrote:
> At the beginning of a paragraph which has been separated mid-sentence
> onto separate lines, how might I automate the process of calling CTRL-J
> until all the separated lines in the paragraph have been combined into
> one line? Will Vim be able to call CTRL-J until a condition is met, for
> example, that the single line being built ends in a sentence (a period),
> or until the next line is a blank newline?
The short answer is go to the top of the paragraph and press Shift+V,
then to the bottom and press Shift+J (not Ctrl+J). You can automate this
further by writing a function that would figure out the top and bottom
of the paragraph via whatever logic you build in. See :help :function.
> Then, how might I automate the process of entering N newlines between
> every sentence? I.e., automating pressing ), i, enter a few times, then
> escape, for multiple sentences? I could create a shortcut to execute
> these commands and call it myself, or it could also repeat until the
> conditions above. How would I do either?
Example, for N = 4:
:imap <F9> <CR><CR><CR><CR><Esc>
Type the actual < and > characters as shown. To use this, at the end of
typing your paragraph do not press Esc but press F9 (or whatever key you
mapped).
If you sometimes want to insert N blank lines in already-written text,
add this:
:map <F9> A<F9>
The previous map was active in insert mode; this one is active in normal
mode. It moves to the end of the current line ("A") in insert mode and
then appends the insert-mode version of F9.
Once you've verified that these work as you wish, you can put them in
your $VIM/_vimrc file so that they will be executed whenever you start Vim.
> Also, how do I go back to where the cursor previously was, in case I
> accidentally move it?
`` or ''
(One goes back to the _line_) where you were; the other goes back to the
exact position within the line.)
--
Stan Brown
Tehachapi, CA, USA
https://BrownMath.com
https://OakRoadSystems.com
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/d9ee4264-13cb-eef7-be14-e0e68f9df155%40fastmail.fm.
Friday, April 16, 2021
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment