Author

The Archives

  • 05.15.12
    ASCII codes in Vim shell | n0str0m0 | (0)
    Today, a work mate asked if anyone had an ASCII code table at hand. He was editing a file in Vim and wanted to know the ASCII code for a certain character. Here is the answer: While having the cursor on the character, type: <ESC>:ascii<ENTER> Enjoy!
  • 03.06.12
    Colored diff shell | n0str0m0 | (0)
    As a programmer I am used to dealing with diff files. If you do not know what a diff file is, here you can find a nice description. They are simply text files so they can be viewed with less, more, cat and other common utilities. The main problem is that those utilities do not recognize these files' special syntax. cdiff (/usr/ports/textproc/cdiff) is a small utility that shows diff files in a colored fashion. It can be used this way: $ cdiff file.diff Of course, Vim can be useful here too ;) svn diff | vim -R - Enjoy!
  • 01.09.12
    Greping from inside Vim shell | n0str0m0 | (0)
    Hi there, First things first: Happy New Year! :) One task I usually perform when I am writing code is grepping the code for a certain string. In order to do that, I used to exit Vim (either with :q or suspending the process), grep the files and then go back to my Vim session. This approximation has one main drawback: I usually don't remember all the matches reported by grep. Vim provides a mechanism for invoking grep from a Vim session. The command is: :grep string files This way, one can invoke his local grep command and the results will be integrated into the ...
  • 10.15.11
    Creating shell archives shell | n0str0m0 | (0)
    shar(1) is a FreeBSD base system utility for creating shell archives that is, a kind of self-extracting archive of a hierarchy of files and directories. The archive will recreate the file hierarchy specified at creation time. It is fast and the result is easy to handle as the shell archive is a text file (good to email a file hierarchy). To create a shell archive: $ shar `find my_directory` > my_hierarchy.shar To recreate the hierarchy: $ sh my_hierarchy.shar That is, shar is a simpler version of ar and tar. Enjoy!
  • 09.13.11
    Audio settings on FreeBSD shell | n0str0m0 | (0)
    mixer(8) is a FreeBSD base system utility for setting and displaying sound card mixer levels. It resembles the Linux's command line utility alsamixer. Invoked with no parameters it shows the current values of the mixer devices: $ mixer Mixer vol is currently set to 85:85 Mixer pcm is currently set to 75:75 Mixer speaker is currently set to 75:75 Mixer mic is currently set to 0:0 Mixer mix is currently set to 0:0 Mixer rec ...
  • 04.08.11
    Screenshots from the command line (FreeBSD) shell | n0str0m0 | (0)
    vidcontrol is a nice utility that among other things allows one to capture the state of a video buffer and dump it to a file. The format of this file is specified in the man page as it is not a regular image file. For this reason one needs a specific tool to convert it to something one can play with. These commands are scr2txt (/usr/ports/textproc/scr2txt) and scr2png (/usr/ports/graphics/scr2png). They can then be combined using one single line: $ vidcontrol -p < /dev/ttyv0 | scr2txt > /tmp/screenshot.txt The -p flag instructs vidcontrol to get the current content of the corresponding video buffer. ...
  • 02.04.11
    Easy svn blame vim mapping shell | n0str0m0 | (0)
    The other day, this colleague of mine asked me how he could use svn blame on the same file he was editing without leaving his vim session. This is a mapping I wrote for that purpose. :map <F3> :sp %.tmp_svnblame \| :r! svn blame $(basename % .tmp_svnblame)<CR> Enjoy!
  • 12.21.10
    Limiting resources with limits (1) shell | n0str0m0 | (0)
    limits is a FreeBSD's base system utility for displaying and setting system resources limits. To some extent it is equivalent to the limit and ulimit commands. It can set limits for filesize, coredumpsize, maxproc, memoryuse and other parameters. Convenience modifiers like k, m or g for kilobytes, megabytes and gigabytes or s, m, h for seconds, minutes and hours can be used in all cases. limits can be used to achieve three different goals: Set resource limits. For example: $ limits -t 1s ls -R / launches the ls -R command with a cputime limit of 1 second. In general, this is the ...
  • 10.23.10
    Vim. Macros shell | n0str0m0 | (0)
    You have probably seen something like this in other editors. Macros (or "complex repetitions" as Vim's help puts it) is a way to repeat complex commands sequences. In order to get the most out of this feature, you need to master movement and insertion commands. The work cycle is the following: start recording, execute commands, stop recording. Then, you are ready to execute the whole sequence of commands you have recorded. Let us see this in more detail. To start recording, we use the "q" command followed by a register name in which the sequence of commands will be stored. qa At that ...
  • 09.04.10
    Vim. Key mapping shell | n0str0m0 | (2)
    Maps are a way to create an association between a set of key strokes and a set of actions. They are really powerful. However, in this post, I will not explain them in the deepest detail. If you need further information, you will need a good Vim manual. As it happens with abbreviations, maps can be used regardless of the mode you are in Vim or they can be restricted to a certain operation mode. They work the same way in every mode. Type :help :map to know which map commands work in which mode. First off, :map ... ... <Esc>OM       <CR> <Esc>Ol ...