Normalize tab spaces - ruby-on-rails

I have a project that has code that was contributed by many people without a proper policy on tab space (I know, huge mistake.)
What's the best way to normalize all tabs to spaces? Optimally some kind of a script that can do this to all files via the command line at once.
I know of Ruby Beautifier, but I didn't have any luck with ERB files (it also doesn't run on 1.9).
Thanks in advance
EDIT:
Forgot to say that we use Mac OS X

There's a command line utility bundled with OS X called tab2space that you might find useful. It's probably available on other platforms too.

I'd say open all files in Notepad++ and replace "\t" with " " (or 4 spaces) with the usual replace dialog. You'll have to choose 'Extended' in the lower left corner and press "Replace in all opened documents".

Related

How to print a file from VsCode?

I want to send the file I'm currently editing to a printer, like I did in Notepad++ for example.
I havn't found any hint on a print command. Is it not possible ?
It is not yet available, but I found an issue report for that feature.
It's currently in the backlog, so we can expect it soon.
https://github.com/Microsoft/vscode/issues/5953
Edit:
In the meantime:
https://marketplace.visualstudio.com/items?itemName=nobuhito.printcode
https://marketplace.visualstudio.com/items?itemName=pdconsec.vscode-print
Now you can install addon for VS Code - search "PrintCode".
Note that the repository for this extension was last updated in February 2018 with numerous issues outstanding.
I found the PrintCode extension inspiring but unfinished and with a number of flaws. In particular it depends on a specific paper size to wrap and as a result does not respond well if you change paper size or orientation in the print dialog.
It's open source so I looked at the code and didn't like that either. No programmer ever likes another's coding style. So I pinched the idea of using a web-browser as platform driver for HTML printing -- my hat is off to the PrintCode author for that cunning insight -- and wrote my own.
In the process I fixed all the known bugs, added everything on my wishlist and a couple of things suggested by others. The biggest thing was figuring out the CSS required to respect print dialog paper size and orientation. This also sorts out the mysterious disappearing line numbers problem, although I'm not sure why. The next biggest thing was learning to probe for an unused port, a problem that also afflicts PrintCode causing the browser to open showing no content.
Major issues
PrintCode depends on a web service. You can't use it offline.
Many people want to be able to open a file, select a portion and print just the selection.
The print dialog supports changing paper size and orientation. This clashes with the way PrintCode works.
Some people like to run multiple VS Code windows.
When you print a markdown file, you probably don't want it printed like a text file when it can be rendered with fonts and proper headings and bullets etc.
Support is required for remote workspaces.
Because each instance of VS Code needs a different port for its embedded webserver, you can't just use a setting. Dynamic port allocation is necessary.
Remote workspaces weren't even a thing until two years after maintenance ceased on PrintCode.
If you want to survey your options, get onto https://marketplace.visualstudio.com, choose the Visual Studio Code tab and search for printing.
If you just want a link to my version, it's here http://marketplace.visualstudio.com/items?itemName=pdconsec.vscode-print.
If you like what you see but need something I haven't thought of, the marketplace page has a link to the repo on github. Create an issue and tell me what you need -- or write it yourself and submit a PR.
Now there is an extension available for printing from the VS Code Editor.
It's called VS Code Printing Free.
I've tried it for a couple of days and it works fine.
Poor man's answer: Copy code to Notepad2 or Notepad++ and print from there.
The colour coding will be different though
You can use an Extension of VS Code: PrintCode
Install extension PrintCode
On Mac: command + shift + P
choose command> PrintCode
I have modified the https://marketplace.visualstudio.com/items?itemName=pdconsec.vscode-print. If you change the values that I have marked in the picture in the extension settings a browser tab opens with the you can then print this also works on the Ipad. It works also with the code-server Version inside a Docker Container.
I put the file on github https://github.com/chrishdx/vsc-print
enter image description here

RubyMine - Turning off ability to click in middle of "empty" lines

I've recently begun learning Ruby and I'm really enjoying it so far. The IDE I've chosen to use is RubyMine (as it's similar to PhpStorm). There is however one feature which annoys me greatly and I cannot find the configuration for.
What I want to get rid of is:
When coding I am able to click in the middle of a line (where I haven't placed whitespace), and the cursor will jump there and allow me to type there (as if I had placed indented the code a long way before beginning to write).
The result might look something like this.
If I clicked in the middle of the line and began typing.
Does anyone know how to turn this feature off?
If my description is too vague, please let me know.
Thanks in advance!
You need to disable Settings | Editor | Virtual Space | Enable placement of caret after end of line
If you find that Allow placement of caret after end of line is already unchecked, try checking the box then exit and restart the IDE. Go back into settings and un-check again. This was the only way I could get it to work on a fresh install of PhpStorm v3.0.3 - no amount of check/uncheck would disable the behavior without this restart sequence.
In Rubymine 4.5 I needed to restart in order to get rid off the carets
In RubyMine 5.4,
File > Settings > IDE Settings section > Editor > Virtual space "section" >
[*] Allow placement of caret after end of line
Remove the check from the checkbox.
It does not require restarting.
In RubyMine 7.1 File > Preferences > Editor > General, Virtual Space section

(Free) Text editor on Windows with a folder view?

I have to stay away from my MacBook and will use Windows for a while. I missed Textmate's folder view when editing my rails projects. Is there an editor on Windows with the folder view? I know there is the E text editor. But I'll save a few bucks if there is a free (cheaper) alternative, as I won't stay in Windows for long ...
Go with gVim, and when editing a file you can type :edit. to pull up the working directory, and navigate from there. Also you get geek cred for rolling VI!
Have a look at Komodo Edit. Some people are already using it for Rails development.
Netbeans is full scale open-source ruby/rails-editor with a folder-view.
Programmer's Notepad is a very lightweigt open source text-editor, it has a "project"-view (but you have to define the project yourself).
The Zeus Lite programmer's editor has a folders view (i.e. View, Navigator menu) feature and it is also free.
Best one I just found.. "programmers notepad".. It's got different coloring for different languages. (though i always turn that off) and it allows you to map keys..
It also has a hand tree view where you can have "magic folders" that show all the files in a given folder. It is very sleek..
One irk.. to make it so you can have two projects open at the same time, you need to go to options and set the exe to allow multiple instances... I'd have rather seen that as default, but it's easy to fix.
Oh and it's free.
Not that you asked, but bluefish seems to be quite good on linux. Has a similar feel. It's a fast little editor.
emacs has speedbar, diredit mode, other option.
This is speedbar:

Sampling Large Data Files

I currently work in the position of Data Warehouse programmer and as such have to put numerous flat files through ETL process. Of course prior to loading the file I have to be aware of its content, the problem is that majority of the files are > 1 GB large and I can not open them using my dear old friend "notepad". Kidding. I usually use VIM or Notepad++ but it still takes a while to open the file. Could I perform a "partial" read of the file using VIM or some other editor?
P.S. I know that I could write a 10 liner script to "data sample" the file, but it would be simpler to convince team members to use a feature of an editor than a script that I wrote.
Thank you for any insight you might have.
If you want to stick with using vim, you could have a look at the LargeFile script.
Alternatively, I've always found that UltraEdit opens large files extremely quickly.
You said you had VIM, that makes me wonder if you have a unix environment as well?
If you like, you can pipe the input through unix utility top and display the raw imput on your screen. Like this:
EDIT: (thanks Honk)
terminal$> head -N 15 file.csv
(Where that 15 indicates you want to see 15 lines only).
Pretty sure there are loads of similar questions, but hey, Textpad is a good choice for this.
use the head command.
Use the 'less' on solaris ... use the same through cygwin on windows. On mainframes this problem doesn't appear, ISPF editor handles it pretty well.
UltraEdit claims to handle files over 4GB...

Configure native vi to emit spaces instead of tabs and not convert autoindent spaces to tabs?

I would like to use spaces instead of tabs when editing Perl scripts with the native vi found on Solaris systems.
I know this can be done with the vim clone, but I don't have access to install vim on these systems as they are vendor locked.
Firstly, is there a way to configure vi to emit spaces when I press TAB?
And secondly, I am also using the auto-indent feature of vi:
:set ai
The problem is, when I manually enter spaces for indenting vi converts groups of 8 spaces into tabs automatically when it does auto-indenting. I guess if I can find a way to turn this functionality off it will be a start.
For an outside-the-box option, could you export the Solaris filesystem using NFS and edit the files you need on another system with a more capable editor?
I believe you want
:set et
(short for expandtabs). I think vi classic supports it.
I realize this is well beyond the best-by date, but I just ran into this issue and was looking for an answer myself. A real pain when editing yaml on a FreeNAS box.
Anyhow, I successfully dealt with the issue by setting the value of tabstop to a large value.
':set tabstop=1000'

Resources