Path: csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.alt.net!not-for-mail From: owl Newsgroups: comp.os.linux.misc Subject: Re: Linux Command-Line Editors Vulnerable to High-Severity Bug Date: Wed, 19 Jun 2019 19:49:48 +0000 (UTC) Organization: O.W.L. Lines: 93 Message-ID: References: <87o92vkihl.fsf@usenet.ankman.de> <0a8ptf-ogu.ln1@Telcontar.valinor> <7mgptf-cg4.ln1@Telcontar.valinor> NNTP-Posting-Host: boom.rooftop.invalid Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Face: $BHf)vM$6p_?9L`jmOQ54JeNyL+%MZGGRfH8&grb[Y%-jU`MCPAQN=/SVDa{(/67bP(YB}rjV^h>cUh Xref: csiph.com comp.os.linux.misc:27281 Georges wrote: > Le 19/06/2019 à 20:23, Charlie Gibbs a écrit : >> On 2019-06-19, owl wrote: >> >>> In alt.os.linux Carlos E.R. wrote: >>> >>>> That the vi help today shows the h j k l keys in its main page shows its >>>> age and obsolescence. Enough to having me running away - and I'm old >>>> enough to having seen it, but the first keyboard I bought around 1984 >>>> had arrows. Verified in my personal museum just now. >>> >>> My first keyboard was a typewriter in 1975. Not one of those newfangled >>> electric ones either. A real man's typewriter that required a strong >>> pounding of the keys and a swipe of the hand for a carriage return. :) >> >> Been there, done that (although about 15 years earlier). I always hated >> the letter P, because of how hard my right pinky had to work to make it >> come out clearly. >> >>>> Don't take me wrong, I know that vi is a very powerful editor. But >>>> boasting of the h j k l is enough to send me running away from it again. >> >> Ironically, I bet a lot of the people who would shy away from vi's hjkl >> play computer games and have no problem with w (forward), s (back), >> a (left), and d (right). (I think of "w" as meaning "walk".) In fact, >> some gaming keyboards even have those keys in a different colour. >> >>> The hjkl navigation is more efficient than the arrows, since it doesn't >>> require that you either make an awkward pinky reach or possibly move >>> your hand from the home row. But even given that, the h and l are >>> better reserved for character navigation within a word, since w and b >>> (forward and backward by word) are otherise more efficent. But the real >>> power of vim navigation comes from the fact that these commands can be >>> given a count. For example, 20j or 20k to go down or up by twenty lines. >> >> Or 3dw to delete three words. >> >>> Then there are '(' and ')' for sentence navigation, and '{' and '}' for >>> paragraph navigation. And let's not forget gj and gk for navigating down >>> and up by visible line in a word-wrapped block. And all of these can >>> be given a count as well. And jumping to line N with :N. And marking >>> locations with 'm'. And passing a range of lines to the fmt cmd with >>> :12,20!fmt. It just gets better and better the more you use it. :) >> >> A lot of those are tricks I haven't gotten around to learning yet. >> My favourite newly-learned trick is "/\", to search for "word" >> without stopping on strings containing "word". It's a great way to >> look for variables like "i" without getting hundreds of false hits. >> >> Another of my favourite tricks is to put the cursor on a brace, >> parenthesis, or bracket and hit "%" to jump to the paired one. >> >> Then there's "ddp", which swaps the current line with the one below it. >> >> So much modern software seems to be designed to continually force >> people's hands off the keyboard in favour of the mouse. The hjkl >> usage means you don't even have to move out of home position to >> hit arrow keys (although I do appreciate having them as an option). >> But then, most users are hunt-and-peck typists who have no idea >> what we're talking about... >> > > In fact, with 'vi', though I think it is possible with emacs, you do > need to look at your screen... If you know your file, or know what you > want to suppress or replace ;) > > My favorite trick to prove 'vi' is quicker than a mouse editor : > > Let's consider a file with 2 columns (or more of course), separated with > or or whatever you want, you need to invert columns : > > aaaaa bbbbb > aaaaa bbbbb > > :1,$s/^\(.*\) \(.*\)$/\2 \1/ > > bbbbb aaaaa > bbbbb aaaaa > > ;) > You can replace the '1,$' with '%'. ('%' means the whole file). You can also use the \v switch to eliminate the need for escaping the parentheses: :%s/\v^(.*) (.*) (.*) (.*) (.*)$/\2 \1 \4 \5 \3/g You could also let an external program do the work: :%!awk '{print $2" "$1" "$4" "$5" "$3}'