Page 1 of 2
Vim replacement with cut/paste to remove hidden characters
Posted: Sat Feb 21, 2015 5:15 am
by bowlesj
Hi,
I figured out how to ask this question in one sentence. "Does anyone know of a fairly low memory use Linux editor that can be run directly from the bash command prompt and which once running can cut/past back and forth from windows notebook editor to strip out hidden characters". However, if you want the long story that led to this short question (and which may explain anything that is not clear about the question) the full story is below.
Thanks,
John.
======================
The full story:
yesterday I used vim to create the standard tiny file to to display the phpinfo. Somehow I managed to introduce a hidden character that caused that file to not display the phpinfo properly. So I deleted the file and recreated it and this fixed the problem. I got thinking about this and it realized it is a big problem since I could be creating a very large file and not want to delete it and create it.
So I see two solutions.
1/ Lots of date/time stamp backups which can be done easily and fast (something I have set up with MS-access).
2/ a Vim replacement with cut/paste to remove hidden characters..
Regarding #2 what I do in Windows is if hidden characters occur which are causing a problem I cut and paste everything into the windows notepad, save it and read it in then cut and past it back in to the document (problem solved). I find I have to use this off and on for some forums and occasionally in other situations such as the phpinfo example. However, I could be wrong but I don't think I can do this with Vim. I was using Google/Youtub to try to find an editor that could do this (one that can run on a very small Unix VPS with very little memory such as 384 meg and as a result one that does not require Unix Wine as Notepad++ does). Yeah, I had a list of at least 10 editors and searched for about 2 hours and I could not find a tutorial that showed the start-up of the editor from the linux bash command line indicating it did not need a memory hog GUI interface. So I just figured out the short question to save people reading time and I copied it to the top.
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Sat Feb 21, 2015 3:04 pm
by Christopher
bowlesj wrote:"Does anyone know of a fairly low memory use Linux editor that can be run directly from the bash command prompt and which once running can cut/past back and forth from windows notebook editor to strip out hidden characters".
You mean besides vi/vim? You can do search/replace from the command line to remove characters.
bowlesj wrote:Somehow I managed to introduce a hidden character that caused that file to not display the phpinfo properly.
Seems list a better solution would be to figure out this "somehow" and resolved it.
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Sat Feb 21, 2015 4:58 pm
by bowlesj
Actually I just realized there are two topics in this thread. You can tell I like to write - LOL.
Topic #1:
The problem is the character(s) was hidden. I obviously can't really prove it was a hidden character but it is the only theory that makes sense because I looked over the code (probably 5 to 10 times) and I could not see any problems. I use to know vi well but it has been 14 years. vim is new to me although similar (or as I thought). I probably hit ctrl+something or alt+something or whatever that vim does not edit for or bypass. It could be my habit from other editors (MS-word, MS-excel, notepad++ who knows). There was one difference in my replacement file which worked. I did it all on one line just in case.
Code: Select all
<?php
phpinfo();
?>
became
<?php phpinfo(); ?>
Actually, come to think of it, MS-word has a shift+enter command and also a ctrl+enter command and I use them at times. So maybe I could do a test for that.
Topic #2:
Actually when I was looking for an alternate editor it was before I had vim installed. I have gotten use to notepad++ for windows. It is so nice (Not that I expect to be doing major editing of parameter files but I have gotten spoilt I guess). After I posted this I got thinking "maybe Vim can do cut and paste". Maybe that is one of the improvements over vi. So I googled it and I found it can.
Google: Vim cut and paste:
http://vim.wikia.com/wiki/Copy,_cut_and_paste
Google: Linux vi versus vim:
http://www.viemu.com/a-why-vi-vim.html
Extract from 2nd link.
There is one thing which is a commonly held piece of knowledge, and which is true as well. It is shown on this page to the best effect. It's the fact that learning vi/vim is an activity that will take a long time (weeks to months), and that the first experience is not pleasant. I take it this is the main reason why vi/vim editing isn't, and will never be, a popular thing. You need to invest quite some effort to learn, memorize, and internalize the 30 or so commands that start making you more productive than with other editors. Since they're all arbitrary one-key commands (although all of them have some easy mnemonic to aid in remembering them, and even some form of coherence), this is not an easy task. It's easy to throw in the towel and go back to familiar jedit or pico, ultraedit or textmate, or even emacs. But once the effort to learn it has been made, I know of no one who goes back. And I know dozens of people that have told me that they've been using 'vi' for over 10 years, and that they're accustomed to and expecting even the smallest details.
After reading this maybe I should try harder to find another editor a bit like notepad++ that does not need unix wine - LOL - one that can cut and paste to windows notepad to strip hidden characters. So much to learn coming back to Unix

Re: Vim replacement with cut/paste to remove hidden characte
Posted: Sat Feb 21, 2015 6:04 pm
by Celauran
Honestly, it would probably be faster to just learn Vim. Yes, it takes years to really learn, but you can get the basics down in about an hour. Copy/pasting should be pretty straightforward, especially if you're using something like Putty to connect to the remote server. 'set paste' and 'set nopaste' might be worth remembering.
On an only somewhat related topic, if you're using Notepad++ day to day, you should really check out Sublime Text.
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Sat Feb 21, 2015 7:44 pm
by bowlesj
Thanks Celauran, I agree with everything in your post. I checked out a video on sublime text. It looks really good. I am assuming it starts from the Linux bash prompt. I am using Putty and I have WinSCP installed but I have not tried it yet.
I have an objective over the next 4 weeks. It may be unrealistic but it can be delayed if it is.
1/ get the PHP & MySQL version at home and on the VPS lined up enough that I can make website changes at home and load them up to the VPS (week 1)
2/ get the website up there and test the website for a week (week 2).
3/ learn minimum Unix administration and set up a routine (week 3)
4/ learn minimum MySQL administration and set up a routine (week 4)
5/ decide if I am ready to point the domain name at the website and open it up so people can discover it (more pressure but not too much yet).
6/ when I feel ready, point the domain name at the website but don't promote it (a bit more pressure - I gather it won't pick up very fast even if it is great)
7/ when I am ready start promoting it locally (emails mostly low budget).
8/ learn to monitor the website and try to figure out if it might take off during this year. I have some basic stats I programmed in to track it at this point.
The main thing is one learns faster under pressure and you tend to only learn what is really important but I need to sort of feel it out as I go.
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Sun Feb 22, 2015 12:58 am
by Christopher
I am not sure you have actually asked a question here, but are more thinking outloud and asking for comment.
As far as a programming editor, it is one of the most personal choices that programmers make. Find one you like. I think Celauran like lighter weight editors. I tend toward IDEs like NetBeans or Eclipse. All are good solutions, so find the one that suits you.
Regarding using vi. If you are going to spend much time on the Unix command line, you need to learn vi. I am not sure about the learning curve you wrote about. You can be quite productive with very few commands:
- arrow keys to move the cursor
- i to enter insert mode, Esc to exit insert mode
- ^ for beginning of line, $ for end of line (the same as in regular expressions)
- x to delete a character (X to delete to left)
- dd to delete a line, yy to just copy it
- p to paste the deleted/copied line
- u to undo
- /<text> to search, n for next match (N for previous match)
- :w to write the file, :q to quit the editor, :wq to write and quit
That's only about a dozen commands. None of those ever struck me as that cryptic. The fact that vi just works everywhere makes it very handy to know.
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Sun Feb 22, 2015 9:20 am
by bowlesj
Thanks Christopher, your list of commands has brought back some memories which will help and I can refer to it too. Lack of comment about my months plan has helped me realize that the schedule may not be unrealistic. I was going to write a lot about the reading material for the remi work but I guess I should stop. I will just say that I managed to get a series of very good google hits for study and I may be able to get PHP 5.5.? in by Tuesday (touch wood). With me you generally just need to point me in the correct direction. Celauran's coment below from the other thread was very helpful in regards to pointing me in the correct direction. I have gone back and read it a few times. Knowing a bit more above Vi will help with updating the /etc/yum.conf file.
You generally don't bother to change the repositories in yum. Your distro will handle that for you. As bug fixes and security patches come in, they will be updated in your distro's repository and available through yum. If you're stuck with a really old version of PHP due to CentOS, you can check out Rémi's repos.
As a result of the above comment and lots of google searches I think these pages will fill in the details I need to go after the remi material. So I should be okay now.
https://www.centos.org/docs/5/html/5.2/ ... mconf.html
http://www.centos.org/docs/5/html/yum/index.html
http://www.centos.org/docs/5/html/yum/s ... cepts.html
http://www.shayanderson.com/linux/cento ... php-55.htm
http://rpms.famillecollet.com/
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Sun Feb 22, 2015 2:45 pm
by Christopher
bowlesj wrote:Lack of comment about my months plan has helped me realize that the schedule may not be unrealistic.
I think all long term plans are generally suspect in software development. I'd recommend taking an agile/spiral approach. List the things you want to do and then pick the most important thing on the list -- do it. Now you are smarter. Look at the remaining things on the list and pick the most important one -- do it. You may notice that each iteration your list may change because of the insights you get as you built things. This approach keeps you focused on what is important, it keeps you producing working software, culls things you thought you needed but really didn't (YAGNI, Premature Optimization, etc.), reveals important things you hadn't thought of, etc., etc., etc.
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Sun Feb 22, 2015 5:10 pm
by bowlesj
Thanks Christopher. I think I more or less do that. Yeah it is hard to plan in too much detail too far ahead. I go back to my todo when a chunk is done and organize it a bit farther out each time. They are always in MS-word or MS-excel. Lately in MS-word in outline format since it is so handy for collapsing/expanding on each level and easy to move chunks. Tonight I start the reading in the links above. I am going to write down questions I don't have answers to and come back to them repeatedly until they are all answered. I will use MS-word outline view so I can indent the answer under the question. I am hoping being active will help me stay awake and retain better too.
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Thu Feb 26, 2015 7:51 am
by bowlesj
I got the vim cut and paste to work for copying and pasting multiple lines within vim and I also got it to 99.5% work for cutting and pasting text in from the MS windows clipboard.
The method is found in the link I found earlier in this thread but you have to read farther down than I originally did.
http://vim.wikia.com/wiki/Copy,_cut_and_paste
They do not explain copying and pasting multiple lines within vim very well. Here is exactly how to do it.
To copy multiple lines all at once within VIM:
1/ position the cursor at the start of the first line you want to copy.
2/ Press shift can capital V.
3/ Press down arrow to highlight as many lines as you want to copy.
4/ press small letter y. (this puts the data into vims memory - you see x lines yanked at the bottom).
5/ move the cursor to the line above where you want to place the copied lines. I place the cursor at the start of the line.
6/ press small letter p. (you can press capital P to paste these lines above the line you are sitting on)
To Copy in from the windows clipboard:
1/ In your windows program or whatever, highlight the characters/lines you want to copy
2/ Press Ctrl+C to copy the data which is highlighted into the clipboard.
....Note: If I suspect there might be hidden characters in the text I am copying, I place the data into MS-notepad first, save it, close notepad, read it back in and repeat #1 and #2 in notepad.
3/ Now go to vim and place the cursor at the start of the line you want to copy data before (not after but before)
4/ Press Shift+Insert.
5/ You will be missing the first two characters only (at least that is what happens on my system) so you need to insert them manually.
Having said all this I did read this. "
What about Vim's copy and paste did you find difficult? I find it really easy, so perhaps there is something in your Vim configuration that could be improved. For example, some GNU/Linux distributions include a vim that doesn't have the X11 and clipboard support necessary for proper copying and pasting in a terminal.".
Final note. I may never need it but there does not seem to be a way to copy multiple lines from a vim document over to an MS-windows based document using the clipboard. At least I could not figure it out quickly.
Close to topic: here is a pretty good summary of vim commands.
http://www.radford.edu/~mhtay/CPSC120/V ... mmands.htm
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Thu Feb 26, 2015 8:08 am
by Celauran
Slightly off-topic, but I was re-reading the thread and came across one of your stated goals:
1/ get the PHP & MySQL version at home and on the VPS lined up enough that I can make website changes at home and load them up to the VPS (week 1)
Check out Vagrant. Don't muck with your live server where breaking things can have real implications. Vagrant will allow you to get a VM up and running that mirrors your production environment (almost) exactly. (I added the almost because of cPanel weirdness). Developing on Windows and deploying to Linux is bound to have some gotchas. Catch them in development.
http://www.vagrantup.com
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Thu Feb 26, 2015 8:11 am
by Celauran
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Thu Feb 26, 2015 10:41 am
by bowlesj
Thanks Celauran. I just checked the links. They look quite interesting and potentially useful for sure.
Since this is general discussion I guess it is okay to bring up this topic. Funny you should mention goals. Actually the editor is a small problem and it is more or less solved. I got back to looking at the copy and paste of multiple lines because I hit a much bigger block to the goals (my lack of knowledge of FTP and fire walls - I am a programmer, not a system admin person). However pushing ahead (not realizing I was headed for quick sand) I discovered "yum install vsftpd" (and some basic commands) then eventually "yum install iptables" and some related commands. Eventually I realized ipTables is probably 6,000 times more complex than I will ever need (For a few reasons I am not all that worried about hacking of my website but I could be naive). So sticking with some caution (and wanting to get my pages up to then VSP) I find some basic iptables already worked out and I figure I can dump one of them into the iptables file to get going but I want to do multi-line cut and paste so I get back to the topic of cut and paste for vim and I put more effort into solving that issue this time (and I found the solution as you know). So I then get back to finding those basic iptable entries and I discover that although my idea may open up the firewall to get the webpages up by using this (allow everything firewall
http://www.noah.org/wiki/Iptables) if I come back to add a bit of security I am going to be spending a year learning these ipTables (forget about helping my website users - LOL). So I have been digging around looking at simpler realistic approaches and currently I have been studying these links.
10 Useful Open Source Security Firewalls for Linux Systems (free for my starter/learning budget VPS system)
http://www.tecmint.com/open-source-secu ... x-systems/
Then I see the bottom one from the above list (ConfigServer Security Firewall) and I go to this page.
http://configserver.com/cp/csf.html
In terms of what it supports it looks good so far since it covers everything I have been looking at in terms of web hosts. It looks like it will run on my mini starter VPS.
The next question is how much time is required to learn it (can I set up a basic default Firewall / FTP setup and tweak it later if hacker problems arise or in anticipation of that happening).
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Thu Feb 26, 2015 11:01 am
by Celauran
iptables isn't that difficult and is definitely worth learning. Take a look at this.
https://help.ubuntu.com/community/IptablesHowTo
Re: Vim replacement with cut/paste to remove hidden characte
Posted: Thu Feb 26, 2015 11:14 am
by bowlesj
Thanks Celauran. Yeah, it seems to hit the nail right on the head for what I need right now. I will have it read in a bit. John.
I was looking at this and not sure if it could run on CentOS.
https://help.ubuntu.com/community/UFW