Monday, October 15, 2012

Finding perfect text editor part 129021: Emacs

I'm putting my emacs configs back to all my linux machines. New prelude based configs, nice and shining (and working) with Emacs 24. Configs are machine based (work machine - different projects from home machine).

Some of nice plugins in My config:

  • GPicker
  • Multiple-cursors
  • php-mode
  • twittering-mode
  • and many many more ... see install_vendors.rb for details.


TODO

  • yasnippets integration with used PHP projects (Symfony1 Symfony2 Silex) - rewrite existing vim   snippets (UltiSnips) python -> elisp.
  • find some  system independent nice way to run emacs server on system startup,


After cleaning up configs from unused mess my emacs starts 2 times faster.

My config on bitbucket: https://bitbucket.org/exu/emacs.d



img: my emacs

Sunday, September 9, 2012

Handling archives in linux (ranger file manager)

Today I was looking for a some plugin for unpacking files in Ranger file manager. I found great tool ( atool :) ). It is nice and simple command for packing and unpacking many types of archives.

First install atool, in ubuntu you do it with apt-get:
sudo apt-get install atool


Now update your rc.conf in ranger (after default instalation you need to copy-config from default skeleton. ranger --copy-config all). Now edit your bindings in ~/.config/ranger/rc.conf

map Pu shell atool -x %s
map Pa shell atool -a %s

Now after pressing Pu/Pa archive is unpacked or directory/file is packed.

Tuesday, July 3, 2012

VIM - share current file in your LAN (for one person)

Inspired by César Bustíos Benites I've made nice VIM key map to share my current file using NetCat tool.

map <Leader>= :!cat % \| nc -l 5555 &<CR>:let @+='http://10.0.0.89:5555'<CR>

You can change port and IP address to your own. Now I'm pressing ,= followed by (my leader is ",") and Ctr-V (Shift-Ins) into my friend IM window :) (Of course everything in LAN)

What above nc command do?
Echoing file content and pipe it to nc which listen on given port and if connection from client begins netcat returns piped content to client, that's all.

VIM - Python Koans plugin

Yesterday i start (again) python koans, and switching into terminal to run again and again pissed me off. So from now i press 1 combination and shell has gone away :), koans run in background and My lovely editor put cursor on last error.

Meet the VIM python koans helper:

https://github.com/exu/vim-python_koans

Output format sucks a little (because my VimL skills sucks - I didn't find solution for this ^@ ^] symbols) but it is great productivity improvement.


Picture 1: Output window with cursor on last error

Thursday, June 21, 2012

Merge many PDF files into one in linux shell

Do you want to merge many PDF files into one? There you are:

Shell code:
$ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf

- out.pdf - destination file name
- in1.pdf, in2.pdf - source file names

(gs - Ghost Script - on Ubuntu 12.04 and OpenSuse 11.3 is installed by default)

VIM - inserting UTF-8 symbols (digraphs)

In VIM in very simple way we can insert some of UTF-8 symbols. List of available symbols we can display by running  :digraphs command


If you locate interesting symbol, you can insert him by pressing  <C-k> key combination and two letters on the left of that symbol on the left. For example equilateral triangle right ordered <C-k>PR
and here you are.



I've tested this technique in UTF-8 encoded files (in LATIN-1,2 or other there could be problems).

Linux Shell Tips - rm exclude emulation

If you want to remove all files and sub-directories from directory exept some files you can use  rm and find combination as described below: :

rm -rf $(find . ! -wholename './web/index.php' ! -wholename './web/.htaccess' ! -name '.' ! -name 'web')

You can see more find power examples on  http://www.infoanda.com/resources/find.htm

Linux Shell Tips - watch

If you want to monitor some command execution in time like "tail -f" for files, probably your linux box have nice solution for you:

watch -n 1 'ls -l'

Where:
'-n 1' - time (in seconds) to refresh command output
'ls -l' - command to execute in interval above

When we add '-d' option (help: highlight changes between updates), watch inform Us what was changed between command executions.

Example for 'ls' command below:


watch --color -n 10 -d 'ls -la'

Output:



After change in directory structure watch informs us about changes:

Monday, June 18, 2012

VIM faster Text-blocks with onoremap

I've found nice VIM feature to add mapping to operators

onoremap p i(
onoremap m i{
onoremap " i"
onoremap ' i'

Now i can press
c' d'
to use defined text-blocks

This technique didn't work with visual mode (you must press vi')

Friday, June 15, 2012

VIM + gpicker = SublimeText 2 like files fuzzy searching

Authors of SublimeText2 make great job with Fuzzy searching. In the past I've used Command-T and CtrlP plugins but both of them doesn't works well for me. Then i found Gpicker project it is written in C so its very fast and can be used in two most powerful editors: VIM (gpicker.vim) or Emacs (gpicker.el). I'm using now gpicker for both of them. It's not so powerful like SublimeText but it get the job done very well.

You can install gpicker in ubuntu

$ sudo apt-get install gpicker

Next step is to configure your favourite editor. In VIM you must put gpicker.vim to ~/.vim/plugins directory (or use any other technique pathogen, vundle or whatever). In emacs you must load gpicker.el in your init.el file (I'm using prelude for that ~/.emacs.d/vendor/). It is working out of the box for me (Ubuntu 12.04, Vim 7.3.429, Emacs-snapshot - 24.1.50.1).

My key bindings in VIM:

map <Leader>p :GPickFile<CR>
noremap <C-p> :GPickFile<CR>
map <Leader>. :GPickBuffer<CR>


Final result:

Gpicker in VIM


Gpicker in Emacs



You can use it in shell too: 


You can look in my vim dotfiles for more information. If you want try my VIM configs you can run command below in your shell

$ curl -L https://raw.github.com/exu/vim-dotfiles/master/gitinstall|bash

WARNING this command will kill your .vimrc file and .vim/ directory so BACKUP your old configs! look at https://raw.github.com/exu/vim-dotfiles/master/gitinstall for more details