Text editor joy!

Questions about applications and software
Forum rules
Before you post please read this

Text editor joy!

Postby aehjr1 on Tue Oct 27, 2009 2:01 am

Some weeks ago, I asked in a post "What's your favorite editor?" I asked because I, although not exactly a vi/vim novice, found fault with the File, Open dialog box in Gvim (Graphical vim). I found it (then) to be more difficult than I thought it should be to edit HTML.

Some things have changed in a few short weeks. I have to give kudos to vim/Gvim and the vim plugin, HTML.vim. I also want to thank everyone who responded to the original post with vim suggestions and their favorite editor.

But this post is mostly to share my text editor joy; using Gvim to edit HTML files. (Note, I refer here to only Gvim, not vim in a terminal.)

One problem I had was that the current Linux implementation of Gvim is "broken" in that the File Open/Close dialog boxes do not use the API's of the OS as they do in Windows. (I regard this as neither good nor bad; I was told of Gvim for Windows only a year ago and only used it in that environment till the past August when I installed Mint.) Of course, my intent was to open the dialog, navigate once to a folder, then reverse time order the listing to get the most recent file.

Only after searching many days did I stumble upon a simple solution. As vim natively can use the standard "netrw" plugin to "edit" a directory, and within the netrw framework change both the attribute and order on which to sort, I write a simple mapping into ~/.vimrc. By experimenting, I find that the order is "sticky"; once sorted by reverse timestamp, the directory listing stays sorted in that order so my new docs get added to the top of the listing. The mapping code (below) show I mapped "lh#" to key strokes to change directory to a folder I have in a Windows partition via symbolic link (winDocs), then "edit" the current directory (":e ."), and finally use netrw commands to change attribute sorted to Time then reverse the sort order.

Code: Select all
:map lh# :cd /home/aehjr1/winDocs/HTMLs<CR>:e .<CR>s r


One problem solved for good, especially as I can save a new article from Firefox into the folder, switch to Gvim and ":e ." to find the newly saved file on the top of the directory listing, cursor down and Enter to edit the file.

The next problem was that when "correcting" curly single- and double- quotes to HTML codes so they display correctly across a range of browsers (an issue with documents saved in charset Windows-1252). I could high-light a quote, bring up the Find & Replace dialog, but the Replace All function botched replace; ironically the Replace function worked correctly, so I would click Replace till the cows came home. I think the reason is the replacement characters--HTML characters--all begin with "&" (ampersand) which mucks up the internal replacement substitution. I can still do all on the command line instead of using a dialog, however, some characters have no mnemonics but use numbers instead. This is more difficult.

A plugin comes to the rescue. After installing the HTML.vim plugin, I have an extra menu item when editing an HTML file (Gvim only, not terminal vim) which gives me literally dozens of new abbreviations, almost impossible to stumble across. One of these in particular is handy, as it--in visual mode only--reviews the character high-lighted and converts it to the approved HTML code (most of which are numerics). Unfortunately, I still can't do global replaces on most of these as I can't type the "correct" (actually incorrect) character into the substitution command, and although going visual then using the dialog box captures the bad character, the Replace All still doesn't work. But, I can relatively easily spot the problems, go visual then two keypresses and the character changed.

To add to the mix, the HTML plugin comes with a modifiable template to start editing from scratch, the ability to high-light text then enclose the text in whatever HTML tags are desired and some other goodies. For me, things can only get better and faster.

To cap it all off, I finally learned how to use the visual mode, and use it pretty efficiently. :D I finish with one story.

Over a decade ago when I started switching from mainframe development & analysis to UNIX/Oracle, one contractor (trying to teach me a few arcane vi commands) told me that he had worked at dozens of installations. Some had EMACS, others had different editors, BUT, no matter where he went, he could always depend the server, whether HP, IBM, Sun, IRIX or other, would always have vi. Knowing the 10-15 most common commands will get 90% of the work done, maybe not most efficiently, but at least done. I learned his lesson well.

The more I learn vi/vim, the better I like it. I wouldn't want to write my resume with it, but I'd rather use vi/vim than any other editor when it comes to code.

I hope this helps someone else. I tried to describe my problems well so keyword searches can find them, and also included links when applicable. Thank you again to all who responded before.
aehjr1
Level 2
Level 2
 
Posts: 54
Joined: Tue Sep 01, 2009 2:14 am

Linux Mint is funded by ads and donations.
 

Re: Text editor joy!

Postby mick55 on Tue Oct 27, 2009 2:11 am

Linus Torvalds uses MicroEMACS. :)
Things are more like they are now than they ever were before.

Dwight D. Eisenhower (1890 - 1969)
User avatar
mick55
Level 7
Level 7
 
Posts: 1507
Joined: Fri Sep 25, 2009 2:47 am

Re: Text editor joy!

Postby DrHu on Tue Oct 27, 2009 7:31 am

aehjr1 wrote:found fault with the File, Open dialog box in Gvim (Graphical vim). I found it (then) to be more difficult than I thought it should be to edit HTML.

Glad it worked for you, however if that was the main application use, probably would have been better to have looked at html editors specifically..
--of course I can understand the benefits of using one tool for many purposes..

aehjr1 wrote:Over a decade ago when I started switching from mainframe development & analysis to UNIX/Oracle, one contractor (trying to teach me a few arcane vi commands) he could always depend the server, whether HP, IBM, Sun, IRIX or other, would always have vi. Knowing the 10-15 most common commands will get 90% of the work done

True and useful to use
--also as that contractor said, a standard, possibly people found emacs too awkward /difficult, and wanted an easier solution: programmers are like everyone else, we all want the tools that are easiest for us to use.

However if anyone really preferred a specific editor and became expert in its use, then they would always take it with them
--admittedly more difficult in the days before USB memory sticks..
Last edited by DrHu on Fri Oct 30, 2009 6:01 pm, edited 1 time in total.
User avatar
DrHu
Level 16
Level 16
 
Posts: 6710
Joined: Wed Jun 17, 2009 8:20 pm

Re: Text editor joy!

Postby aehjr1 on Fri Oct 30, 2009 4:42 pm

Well, Dr., I did look at a few HTML editors and they all were missing one ingredient for me--the ability to read another file into the file I was editing. You see, sometimes I want to send some of these articles to friends as email attachments, and I want my very simple CSS to be available all the time without accessing remote servers; this makes in-line CSS a good solution for me. So, it's either open up two tabs, windows or whatever in the editor and high-light, copy and paste--or do a simple "read" command in vim. The result of me finding the functionality I thought I was missing (netrw) was that I map a string to read my CSS file into the current document (in the HEAD block.)

A number of those HTML editors were pretty cool too, though most seemed aimed at creating new pages rather than stripping the scripts and advertisements out of the on-line articles I save.
aehjr1
Level 2
Level 2
 
Posts: 54
Joined: Tue Sep 01, 2009 2:14 am

Re: Text editor joy!

Postby DrHu on Fri Oct 30, 2009 6:19 pm

aehjr1 wrote:A number of those HTML editors were pretty cool too, though most seemed aimed at creating new pages rather than stripping the scripts and advertisements out of the on-line articles I save.
OK, no problem..
True, and a lot are the WYSIWYG model, the visual guide style..

Now I see your replay about css/ html, programatically editing, I think of something like Django
http://www.djangoproject.com/
http://docs.djangoproject.com/en/dev/intro/overview/

But now that you have Gvim working well, no need to use anything else; your solution is no doubt admirably uncomplicated..
User avatar
DrHu
Level 16
Level 16
 
Posts: 6710
Joined: Wed Jun 17, 2009 8:20 pm


Return to Software & Applications

Who is online

Users browsing this forum: Google Adsense [Bot] and 25 guests