[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Does bash have a tool ?

On 05.03.18 03:06, Richard Owlett wrote:
> As to "manpages not a tutorial" <snicker> <snicker> *ROFL*
> I'll admit content is there, but ...  ....
> I've been referred to vim. Although awk and cousins are probably under the
> surface, vim.org is fascinating and accessible to end users such as myself.

A good text editor (and it's hard to be as good as Vim) will reduce the
workload of repeated edits which are not consistent enough to be easily
automated with Sed or Awk.

It's amazing how much can be done by repeating the last search with 'n',
then deciding whether to hit '.' to repeat the last edit (e.g. a
change-word or delete-to some pattern)

There's also the ability to put any sequence of actions onto a key.
If you arc up vim and type ":help q", the on-line help will describe how
to start keystroke recording with "qx", where x is the key you'll use to
re-run the macro, via "@x". Although both search and action can be
packed into the macro, it's usually better to repeat the search (for
next edit target) with 'n', so you get to see the "before", then hit @x
to run the macro, then eye the results before repeating.

Vim is modal editor, with a normal mode and a couple of editing modes.
Thinking you're in insert mode while in normal mode, can in a few
keystrokes wreak random havoc, requiring a stab at Escape then a few
stabs at 'u', the undo button, to restore order. (If too many undos,
then ^r is redo.) To reduce the need to rely on memory, a line with

set showmode

in ~/.vimrc will display the current mode in bold text. (Blank for
normal mode) If you also add these lines:

" Cursor Appearance and behaviour:                                           !!!
" (Insert_Mode == Green, Normal_Mode == Red)
if &term =~ "xterm"
   let &t_SI = "\<Esc>]12;green\x7"
   let &t_EI = "\<Esc>]12;red\x7"

the cursor will also serve as a reminder, so you don't need to glance to
the bottom of the screen.

What serves best varies not only with the task and the tweaks you've
made to the tools, but what techniques you have absorbed on the
text-whacking journey.


Reply to: