{"id":2519,"date":"2011-12-15T08:48:58","date_gmt":"2011-12-15T06:48:58","guid":{"rendered":"https:\/\/iguanademos.com\/Jare\/wp\/?p=2519"},"modified":"2012-02-05T02:30:01","modified_gmt":"2012-02-05T00:30:01","slug":"text-editors","status":"publish","type":"post","link":"https:\/\/iguanademos.com\/Jare\/wp\/?p=2519","title":{"rendered":"Text Editors"},"content":{"rendered":"<p>Programmers spend most of our time in front of a text editor. Whether it is a standalone editor, or one integrated in an IDE, that&#8217;s just what we do.<\/p>\n<p>Back in MS-DOS days, my editor of choice was <a title=\"QEdit\" href=\"http:\/\/www.semware.com\/\" target=\"_blank\">QEdit<\/a>, later renamed to The Semware Editor. I loved its configurability, and remapped pretty much everything in it to suit my preferences. Around that time I was also working on Unix systems and used vi there, although only for short editing sessions. I had been exposed to <a title=\"Emacs\" href=\"http:\/\/www.gnu.org\/s\/emacs\/\" target=\"_blank\">Emacs<\/a> multiple times (starting with MicroEmacs on the Atari ST), but I could never get comfortable with its crazy keyboard combos.<\/p>\n<p>After Windows 95 came and became my regular environment, the best choice was <a title=\"Ultraedit\" href=\"http:\/\/www.ultraedit.com\/\" target=\"_blank\">Ultraedit<\/a>. Very soon, Microsoft Visual Studio became the compiler and IDE of choice for Win95 development, and its built-in editor proved quite powerful, so I would use Ultraedit for editing files that were not C++.<!--more--><\/p>\n<p>The big annoyance with Ultraedit was that, being a paid product, it was not readily available everywhere I could go. At work, at someone else&#8217;s computer, etc. And it seemed to become more bloated with each version. I started looking for alternatives, and settled with <a title=\"SciTE\" href=\"http:\/\/www.scintilla.org\/SciTE.html\" target=\"_blank\">SciTE<\/a>. SciTE is the editor built around the Scintilla text-editing component \/ library. It&#8217;s a very powerful and extensible text editor, but the default installation is rather barebones and lacks many useful text manipulation tools. I was also bothered by the way it implemented rectangular block selections. So I started looking for alternatives again.<\/p>\n<p>The next editor I used was <a title=\"Notepad++\" href=\"http:\/\/notepad-plus-plus.org\/\" target=\"_blank\">Notepad++<\/a>, another editor built around Scintilla. Free, lots of features, and lots of free and easy to install plugins. I was completely comfortable with it, no major complaints. Ok well, yeah, one major complaint actually: the &#8220;Find in Files&#8221; dialog box was fixed in size, and the space available for the listbox of folders to search in was rather short. It was annoying to work with long, descriptive paths. I changed the dialog size and recompiled the editor, but it sucked to do that for every new version of the editor. The other issue with Notepad++ was that I was using Linux (Ubuntu) both at work and on my netbook, and Notepad++ is 100% Windows-only. Oh, and some of the settings are really awkward to configure. Yeah, a great editor, but a number of annoyances.<\/p>\n<p>In text-mode terminals on Ubuntu I had been using joe for quick edits, but for any significant amount of work I slowly started using (and getting used to) <a title=\"vim\" href=\"http:\/\/www.vim.org\/\" target=\"_blank\">vim<\/a> again. Since I was restless with Notepad++, I tried getting used to gvim on Windows, but despite its <a href=\"http:\/\/www.viemu.com\/a-why-vi-vim.html\" target=\"_blank\">many good points<\/a>, I just could not stomach it. When working in a GUI, sorry but I need at least decent multi-file support with tabs, Ctrl-N to quickly create a scratch file, and of course my Ctrl-C and Ctrl-V and common GUI shortcuts; gvim&#8217;s UI is at odds with everything else in the GUI world.<\/p>\n<p>Then someone pointed me to <a title=\"Sublime Text 2\" href=\"http:\/\/www.sublimetext.com\/\" target=\"_blank\">Sublime Text 2<\/a>. Great editor, lots of tools, features, and neat details. Works on Windows, Mac and Linux. Supports the notion of projects. Scriptable in Python, awesome! I have been using it on and off for a while to see if I really want to switch to it. It is a commercial product, and I suspect that some of the old ghosts with rectangular block selections and Find in Files will come back and deter me from ST2, but for now I&#8217;m enjoying it. I wrote a little plugin to add basic Perforce integration:<br \/>\n<!--more--><\/p>\n<pre># Simple Perforce plugin for Sublime Text 2\r\n# (C) 2011 by Javier Arevalo\r\n# Free for anyone to use, distribute and modify\r\n\r\n# Copy this file to ST2's Data\/Packages\/User\/perforce.py\r\n# Add the functions to the Tools menu with the following in a file named\r\n#   Data\/Packages\/User\/Main.sublime-menu:\r\n#[\r\n#    {\r\n#        \"id\": \"tools\",\r\n#        \"children\":\r\n#        [\r\n#            { \"caption\": \"-\" },\r\n#            { \"command\": \"p4_edit\", \"caption\": \"P4 Edit\" },\r\n#            { \"command\": \"p4_revert\", \"caption\": \"P4 Revert\" },\r\n#            { \"command\": \"p4_add\", \"caption\": \"P4 Add\" }\r\n#        ]\r\n#    }\r\n#]\r\n# And\/or in Data\/Packages\/User\/Context.sublime-menu:\r\n#[\r\n#    { \"caption\": \"-\" },\r\n#    { \"command\": \"p4_edit\", \"caption\": \"P4 Edit\" },\r\n#    { \"command\": \"p4_revert\", \"caption\": \"P4 Revert\" },\r\n#    { \"command\": \"p4_add\", \"caption\": \"P4 Add\" }\r\n#]\r\n\r\nimport sublime, sublime_plugin\r\nimport os, stat\r\n\r\ndef UpdateViewWriteability(view):\r\n\tif view.file_name():\r\n\t\tif os.access(view.file_name(), os.W_OK):\r\n\t\t\tview.set_read_only(False)\r\n\t\telse:\r\n\t\t\tview.set_read_only(True)\r\n\r\n# Detect readonly \/ writable files\r\n# These are both false for non-file buffers\r\ndef IsWriteable(view):\r\n\treturn view.file_name() and os.access(view.file_name(), os.W_OK)\r\n\r\ndef IsWriteProtected(view):\r\n\treturn view.file_name() and not os.access(view.file_name(), os.W_OK)\r\n\r\n# Event to catch buffer activation and check readonly\/writeable\r\n# Note: Running the commands doesn't de- and re-activate the view focus,\r\n# so the ReadOnlyCheck event doesn't fire. We call the function manually\r\n# for each command.\r\nclass ReadOnlyCheck(sublime_plugin.EventListener):\r\n\tdef on_activated(self, view):\r\n\t\tUpdateViewWriteability(view)\r\n\r\n# Commands\r\n\r\nclass P4EditCommand(sublime_plugin.TextCommand):\r\n\t\"\"\"P4 Edit\"\"\"\r\n\tdef run(self, edit):\r\n\t\tos.system(\"p4 edit \\\"\" + self.view.file_name() + \"\\\"\")\r\n\t\tUpdateViewWriteability(self.view) \r\n\r\n\tdef is_enabled(self):\r\n\t\treturn IsWriteProtected(self.view)\r\n\r\nclass P4RevertCommand(sublime_plugin.TextCommand):\r\n\t\"\"\"P4 Revert if unchanged\"\"\"\r\n\tdef run(self, edit):\r\n\t\tos.system(\"p4 revert -a \\\"\" + self.view.file_name() + \"\\\"\")\r\n\t\tUpdateViewWriteability(self.view)\r\n\r\n\tdef is_enabled(self):\r\n\t\treturn IsWriteable(self.view)\r\n\r\nclass P4AddCommand(sublime_plugin.TextCommand):\r\n\t\"\"\"P4 Add\"\"\"\r\n\tdef run(self, edit):\r\n\t\tos.system(\"p4 add \\\"\" + self.view.file_name() + \"\\\"\")\r\n\t\tUpdateViewWriteability(self.view)\r\n\r\n\tdef is_enabled(self):\r\n\t\treturn IsWriteable(self.view)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Programmers spend most of our time in front of a text editor. Whether it is a standalone editor, or one integrated in an IDE, that&#8217;s just what we do. Back in MS-DOS days, my editor of choice was QEdit, later &hellip; <a href=\"https:\/\/iguanademos.com\/Jare\/wp\/?p=2519\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,10],"tags":[],"class_list":["post-2519","post","type-post","status-publish","format-standard","hentry","category-development","category-system"],"_links":{"self":[{"href":"https:\/\/iguanademos.com\/Jare\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iguanademos.com\/Jare\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iguanademos.com\/Jare\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iguanademos.com\/Jare\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/iguanademos.com\/Jare\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2519"}],"version-history":[{"count":10,"href":"https:\/\/iguanademos.com\/Jare\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2519\/revisions"}],"predecessor-version":[{"id":2551,"href":"https:\/\/iguanademos.com\/Jare\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2519\/revisions\/2551"}],"wp:attachment":[{"href":"https:\/\/iguanademos.com\/Jare\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iguanademos.com\/Jare\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iguanademos.com\/Jare\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}