未加星标

Switching from Vim to Atom (A Haskeller's Perspective)

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二03 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

Switching from Vim to Atom

(A Haskeller's Perspective)

Posted on March 7, 2015 (last updated Aug 23, 2016)

I have been a Vim user for many many years, but have long wanted to switch to an editor that was more easily hackable. I tried Emacs and Sublime , but both had various hurdles that were just too annoying for me and both times I switched back to vim very quickly. However, I started using Atom a while back, and I have to say, I liked it from the start. I very quickly felt almost as productive as I was in vim, and in some ways I already much prefer Atom. (And since it’s javascript, we can write plugins in Haskell !)

Below are some tips that helped me transition from Vim to Atom.

Multiple Cursors

Multiple cursors, inspired by Sublime I think, are absolutely awesome. Many things that I would previously use a regexp for I now do much more quickly with multiple cursors. For example, here’s an example making a curried function uncurried:


Switching from Vim to Atom (A Haskeller's Perspective)

Note that multiple cursors don’t have to stay in the same column, even if they start out that way. Each cursor responds to key commands independently. This is tremendously useful; for example, consider this example of removing parentheses:


Switching from Vim to Atom (A Haskeller's Perspective)

Nor do they have to be on consecutive lines as in this example of removing some linebreaks:


Switching from Vim to Atom (A Haskeller's Perspective)

On Mac, Shift-Control-Down (or Up) extends the cursor to the line below (or above). (You will want to disable the Mission Control and Application windows shortcuts .)

Indentation (No) Auto-indentation

I hate editors that try to be smart about indentation with a passion. I’ll decide my own indentation, thank you very much. The only thing I want an editor to do by default is to copy the indentation from the previous line (vim’s :set ai ). Thankfully, Atom does this out of the box.

(No) Tabs

One thing that is a bit annoying with Atom’s default settings is the treatment of tabs. By default, it’s using soft tabs, and that’s good, but it tries to be smart about recognizing multiple spaces as soft tabs and that’s not so good. The problem is that in Haskell code (in mine at least?) the indentation is not always an even number of “tabs”; instead, the indentation is dictated by the code. Here’s an example of where this can go wrong; all I do in this screencap is press space and then backspace:


Switching from Vim to Atom (A Haskeller's Perspective)

This gets even more annoying when using multiple cursors, because now the behaviour on each line depends on whether Atom happens to recognize a soft tab or not:


Switching from Vim to Atom (A Haskeller's Perspective)

Thankfully, this problem is easily solved by setting the length of a soft tab to 1.

Indentation help

Some help with indentation is useful though ( when requested! ). Multiple cursors can help here too. For example, we can use -D to add the next occurrence of the word or symbol under the cursor, and then use the atom-alignment package to justify each of those cursors:


Switching from Vim to Atom (A Haskeller's Perspective)

Alternatively, if we want to align different words, we can create multiple cursors by -clicking on the keywords we want to align:


Switching from Vim to Atom (A Haskeller's Perspective)
Haskell Support

Writing Haskell code is what I do for a living , and there are few things that I find absolutely essential; thankfully, all of these are well supported in Atom:

Syntax highlighting for Haskell is provided by the language-haskell package. Atom supports CTAGS files out of the box, and it works great with the tags files created by hasktags ; just call hasktags -x -c . in your project directory, and then you can jump to any tag using -Shift-R, or jump to the definition of the symbol under the cursor using -Alt-Down. (Incidentally, I know a lot of professional developers who do not use tags files. Use them! Once you start using them you will be so much faster navigating through source code that you will wonder how you ever did without.) Sadly, symbols-tree-view does not seem to work in Haskell projects, but that’s not a major problem. Support for cabal is available through my own ide-haskell-cabal backend for the excellent ide-haskell Atom package.

Incidentally, the same ide-haskell package also supports ghc-mod , but I don’t personally use it so YMMV. Note that if you do want to use ghc-mod you’ll probably want to use a recent version of ghc-mod (5.4 or up); it should work with either cabal or stack .

Miscellaneous

Finally, a few miscellaneous Atom tips and some non-default packages.

autoflow , installed by default, makes it possible to “reflow” a paragraph, much like gqap and co in Vim. -Shift-F is a project-wide search (with support for regular expressions, of course). For me this has pretty much replaced the use of grep , since the results are of course clickable. I find Atom’s autocompletion of brackets very annoying; I don’t want it to insert a closing bracket when I write an opening one; disable “Autocomplete Brackets” in the (standard) bracket-matcher package. I like using Adobe’s Source Code Pro font; see Atom Initial Impressions by Quinn Rohlf for some info on how to use it in Atom. You might also want to take a look at Hasklig , a fork of Source Code Pro that adds ligatures for many of Haskell’s operators.

I make use of the following additional packages:

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: JavaScriptJavaWindows
分页:12
转载请注明
本文标题:Switching from Vim to Atom (A Haskeller's Perspective)
本站链接:http://www.codesec.net/view/484722.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(41)