Friday, November 30, 2007

What is going on

Hi for who is reading this :P

I'm not posting often because some stuffs are being made here, let me share what is going on:

  1. Learning Django;
  2. Creating a full featured web page;
  3. Documenting slowly the Vim plugins that I made;
  4. Starting the "snippets" plugin for Vim;
As you can figure out, the number 2 is the main thing here. It will be the home of this blog and many other stuffs that I want to share with you.

So, sorry for the quietness here, but as soon as I get something done, I post at leas my new address!

Wednesday, October 3, 2007

"." command doesn't work as expected

First of all I have to thank Kamil Dworakowski who notice this behavior and warn me.

Now, what is happen is after a pair completion, if you exit from insert mode and try to do the last command with the "." key in normal mode, Vim will only reinsert the content that you enter inside the pair chars, e.g:

On insert mode type (123 and exit to normal mode. You should have this:



Now move to any other part of text and press "." (without quotes) and you should see this:



What is happen is that a movement key on insert mode (e.g. <Left>, <Right>, <Down> or <Up>) says to Vim that what will be inserted next is to be kept, the rest forget.

To confirm that make a simple test and you'll see:

  • Go to insert mode;
  • Type 124<Left>3;
  • Go to normal mode;
  • Move cursor to other place;
  • Press <.>;

Now only 3 is reinserted!

This behavior is reflected on TownkAutoCompleteChar because it inserts the "close-pair" and right after that it "insert" an extra <Left> char, making the cursor go inside the pair of chars.

If anyone have any idea on how can I workaround this behavior, please send me a comment or an email!

Tuesday, September 25, 2007

Lack of posts

Hi guys, I know that I was a little bit relapse with my blog, but I just receive a Wii as a gift from my wife and I couldn't stay away of it :P, I promise that soon I'll post news!

Tuesday, September 4, 2007

Other plugins

I took some time to put my hands on other scripts before release the TownkVisualMarks one.

I create a little script that auto complete the (, {, [, " and ' character, just like Eclipse editor do.

Take a look at it here, download it, test it and if you find any bug, just let me know that I'll fix it as soon as possible!

BTW, I also made a little improve on other, already good, script: Autohi (another Eclipse envy :P)

Friday, August 31, 2007

TownkVisualMarks (Screenshot)

I'm solving some issues with balloons and marks but I'm pretty confident that I'll release a test version this weekend.

And just to give you a glimpse of what this plugin will be, here it go a screenshot:



I hope you like it!

Thursday, August 30, 2007

Done!

The TownkVisualMarks plugin seems to be done! I need to run some unit tests on it and if everything pass successfully I'll publish it on VIM.org to evaluation and tests :D

Sunday, August 26, 2007

TownkVisualMarks (development report)

First of all, let me explain what this plugin is:

Its a plugin that puts visual marks on a text file that could be persistent (a.k.a. Bookmarks), dynamics (warning, error and info) or temporaries (quick bookmarks).

As you could see the TownkVisualMarks has (at least until version 1.0) 5 marks that could be inserted into some text file, they are:

  • Information
  • Warning
  • Error
  • Bookmark
  • Quick Bookmark
Three of this marks (information, warning and error) are only inserted into the text through a dynamic way. This means that, like OmniFuncions, a predefined function is called when a buffer is read or saved to know where to put these marks.

The "Bookmark" mark is the one that is persistent, this mean that if you put a Bookmark into any text file, no mater if you turn Vim off or not, this mark will be saved into your .vimfile (only if you have the "!" option added to viminfo option).

If you want just a quick book mark to a file that you are editing right now, than the "Quick Bookmark" mark is for you. This mark is just like a Bookmark but it is not stored on your .viminfo file.

Well, probably this coming week I'll post some more news about this, keep tunned!

Tuesday, August 21, 2007

Update

Ok, I finish the book and boy, this book worth every penny I paid on it!

Well, what I decide to do is separate my entire work in modules and delivery every one on vim.org after I finish it.

The modules that I want to do are:

Visual Marks: use 'sign' command to create visual marks automatically when we get an error, a warning or just a info (i.e. TODO, FIXME, etc) on quicklist (i.e. when use :make command). Also this plugin should allow user to create persistent bookmarks on vim, this way he/she can bookmark a given line on a given file, close vim, open it again and by menu (gVim) or command go right through that bookmark that he/she previously save.

TextMate snippets: I know that there are some plugins that claim to do just that, but my proposal is to create a plugin that reads each snippet from a file that has it syntax exactly like what TextMate propose.

Project Manager: This plugin will be the biggest and most difficult one. As its name says it will control solutions, files, and whatever I found interesting.

Project Tags: This will be the last plugin and it will control the ctags' tag creation to each file of the project.

Well, right now I started the Visual Marks plugin and when I have something that works as I expect that the hole plugin works, I'll publish the file here. In the mean time keep following the blog to get updates about the project.

Friday, August 10, 2007

New Vim book

Since yesterday I'm reading a new Vim book: Hacking Vim (A cookbook to get the most out of the latest Vim editor).

Well I don't have to tell you that this book will help me a lot on this new Vim project!

As soon as I got some news I post here... be prepared to even a change of the name of this blog!

Tuesday, August 7, 2007

The Project Manager

I looked for some IDEs and thought that a good way to represent the project manager is the way that Mono Developer and Visual Studio do this stuff: a window to show "Solutions" and other to show classes from the selected solution.

I did a mockup of this just to put here:


As you can see, the top window will be made using a ctags database that will be generated as we create/expand our project.

Now, the bottom window will contain all of our "solutions" that are nothing more than our projects. This windows must be created and controlled by our own plugin.

Friday, August 3, 2007

"Perfect"??? ctags DB for a .CPP file

Ok, I figure out a way to create at least a good ctags file to a .cpp/.h file being edited.

I use the C Pre-Processor (cpp) that came with GCC but I believe that should be very easy to adapt this to other pre processor. Well, let me show you some code:

function! CreateTag()
  let inc_list = ["/myproject/include", "/otherproject/include"]

  if !has("unix")
    let redirect_null="> nul"
  else
    let redirect_null="2>&1 1> /dev/null"
  endif
  
  let inc_cmd = " " 
  for inc in inc_list
    let inc_cmd = inc_cmd."-I".inc." "
  endfor

  let pp_cmd="cpp -H -M" . inc_cmd . expand('%') . " " . redirect_null
  let register_a = @a
  redir @a>
  exec ":silent !".pp_cmd
  redir END

  " remove every line that doesn't start with a '.'
  let @a = substitute(@a, "^.\\{-}\n\\(\\..\\{-}\n\\)[^\\.].*$", "\\1","g") 
  " remove '.' from beginning
  let @a = substitute(@a, "\\.\\{-1,} ", "", "g")
  " prepare it to be evaluated as an array
  let @a = "[\"" . substitute(@a, "\r\n", "\",\"", "g") . "\"]"

  " convert the founded files into an array
  let file_array = eval(@a)
  " restore register
  let @a = register_a

  " mount the ctags command
  let ctags_cmd="ctags --c++-kinds=+p --fields=+iaS --extra=+q -f /tmp/" . expand('%') . ".tags "
  for inc in file_array
    let ctags_cmd = ctags_cmd . " " . inc
  endfor
  let ctags_cmd = ctags_cmd . " " . expand('%')

  exec ":silent !" . ctags_cmd
  exec ":set tags=/tmp/" . expand('%') . ".tags"
endfunction

I know, I know, its not clean but it was quickly made just for test purpose, but I think that already is a good start!

ps.: If you want to do a plugin with this code, feel free to do it, but just give me some credit ;-)
pps.: I need to find a better way to put codes here, specially with highlighting
ppps.: Stupid me! There is a TOhtml command in Vim 7.1 that does exactly what I want :P

Thursday, August 2, 2007

Things to think

Today I discover some interest thing about code complete in Vim.

I'm using OmniCppComplete and I spend some time figuring out how to create the perfect tag database to a single file.

The "hole project" tags is not what I want because if my file didn't include "MyHeader.h" where is located "class MyClass;" and I use the "hole project" tag I will get the completion for MyClass stuffs anyway.

So, I found a Vim plugin called Intellisense and in a page of this project they explain how it works. I found myself thinking in how can I discover all included files from a single cpp file with tools already available on my Linux box (or Windows).

Well, I'm digging a path through the gcc preprocessor, but as soon as I get something better, I'll put it here.

Tuesday, July 31, 2007

Vim as a C++ IDE

First of all, hi everyone!

This is, probably, my 5th or 6th blog, but my first in English.

The reason for that is that I didn't find any motivation to write on a blog for a long time... so far! But this seems to be changed, last week I found myself with some kind of a problems in work... as good programmer geek I start to use Vim some time ago to do all my developments and I have no complains about that.
The problem is that I'm a little bit lazy and in some situations (specially when I'm working on big projects) I would like to have a good code completion while I'm programming.

Well, you can say that there is OmniCppComplete plugin for that, but the problem with that is not the plugin feature itself, is the background operation needed to make the plugin works: ctags

Yes, one of the best friends of Vim is the bad guy here.

The problem is that if you make a tag DB for your project OmniCppComplete will show complete options to everything inside your project no mater if you "include" the desired file or not, and more, if you try to complete an std::string you'll see where the problem is!

Ok, all that to say that I thought in create some sort of plugin that will automatize this hole process to me and do a little bit more.

This plugin will use some well know plugins already existed in Vim scripts page like:

TagList (ctags helper);
OmniCppComplete (code completion);
SourcecodeObedience (project index);
CRefvim (C reference manual);
CCase (ClearCase integration);
ShowMarks (Enable a visual mark for all "marks" in your file);
SnippetsEmu (TextMate like snippets);

Well... I need to think a little bit more about that, but I thought that putting this on a blog will help me stick firm on that :)