Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

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

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).

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

Friday, May 20, 2011

VIM + PHP: key mapping to find parent class

I love VIM power

map   <Leader>]    /extends /e<CR>:normal l<CR><C-]>

Use with generated ctags!


BONUS! your VIM cowsay powered:
vmap <C-S-F1> yo<esc>:r !cowsay <C-r>"<cr>
0. select block of text and press Control-Shift-F1 key.
1. cowsay needed!
2. Ubuntu installation:
sudo apt-get install cowsay

Friday, April 1, 2011

Embedded data image VIM script

(w nawiązaniu do posta o konwersji obrazka na embedded data za pomocą PHP)

Stwierdziłem że skoro używam VIM'a fajnie byłoby mieć plugina który to zrobi. A ponieważ ostatnio przerabiam python koans a VIM ma możliwość pisania pluginów w pythonie więc wziąłem się dziś do dzieła.

Wynik moich wypocin to kilka linijek kodu w postaci plugin'u do VIM'a Image2Data




Jest to wersja po tuningu, wykrywa automatycznie mime type. Wystarczy dodać plugin do VIM'a, zmapować sobie go pod klawisz a następnie skopiować do schowka link do obrazka a w miejscu, w którym chcemy aby nasz obrazek objawił się w formie data:image...... wykorzystać swój skrót w normal mode.

PS: proszę o wrozumiałość to mój pierwszy plugin w VIMie :p

Thursday, March 17, 2011

VIM tips - edycja

Genialne, czy twój edytor to potrafi ? Mój tak ...

Taki to Nasz super Janek kopnął fredzie w tyłek.
   ^---------------------------^===^ 

d/fred/      #delete until fred
y/fred/      #yank until fred
c/fred/e     #change until fred end

Ten i wiele innych tipsów możesz znaleźć na stronie autora http://rayninfo.co.uk/vimtips.html

Wednesday, March 2, 2011

VIM i .bashrc i wywoływanie cmd przez !

Jeżeli twój VIM na ubuntu nie chce czytać twojego pliku .bashrc, problemem może być tryb interactive, który nie jest włączony przy wywoływaniu komend przez "!". Poniższe linijki pomagają to uzyskać.

set shell=bash
set shellcmdflag=-ic

Może też pomóc przeczytanie dokumentacji
:h 'shell'
:h 'shellcmdflag'