Re: [code] [textadept] A bunch of newbie questions

From: Mitchell <m.att.foicica.com>
Date: Sun, 21 Aug 2016 15:28:06 -0400 (EDT)

Hi Anton,

On Sun, 21 Aug 2016, Anton Pastukhov wrote:

> Hello,
>
> I'm new to Textadept, and I have some questions. I read the manual and the
> wiki, but my Lua and TA API knowledge isn't very good. I'm currently
> migrating from Vim and trying to mitigate inevitable productivity loss, so I
> have some noobish questions:
>
> 1. Multiple edge columns. This can be useful in some cases, e.g. PHP
> PSR-2 mentions two document widths: 80 and 120 chars. As I
> understand, there is no quick way to enable second column in the
> current version of TA, or is it?

There is no way to set two edge columns at a time. Only one can be
defined.

> 2. Delete trailing spaces on demand, not only on filesave?

It was mentioned later, but copy-paste the function that does it from
`modules/textadept/editing.lua` to your `~/.textadept/init.lua` and bind
it to a key.

> 3. Automatically show autocompletion suggestions after n of typed
> chars, without using keyboard shortcut (IDE-like, Sublime-like)?

Connect to the `events.CHAR_ADDED` event and grab the current line and
position on that line with `buffer:get_cur_line()`. Then check the number
of letters behind the caret. If it meets a threshold, call
`textadept.editing.autocomplete(...)`.

> 4. It seems that buffer.indic_style allow to highliht background or
> text (buffer.INDIC_TEXTFORE). Is there any way to use both options?
> E.g. transparent indicator and bright-colored text.

I don't think there's an indicator that allows setting a background and
foreground color.

> 5. Shift + Tab behaviour. Right now it unindents the line only if the
> caret is at the beginning of this line. Is there any way to unindent
> regardless of the caret position?

Redefine the tab key with something like this (untested):

   keys['\t'] = function()
     if not buffer.selection_empty then
       return false -- default tab behavior
     end
     local line = buffer:line_from_position(buffer.current_pos)
     buffer.line_indentation[line] = buffer.line_indentation[line] -
                                     buffer.tab_width
   end

> 6. In Vim, I can automatically indent selection or the whole text with
> gg=G according to the language rules. There is similar option In
> Sublime ("reindent"), but I can't see how to do this in TA, and I
> really miss this feature.

You'd have to redefine the tab key like above to do any custom indent
behavior. That is, if it's anything other than by a certain tab width or
using tabs instead of spaces, etc. If it's simple, than you can define
indentation settings on a language-specific level[1].

Cheers,
Mitchell

[1]: http://foicica.com/textadept/manual.html#Language.Preferences

>
> I will appreciate any help.
>
> Anton.
>
>

Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sun 21 Aug 2016 - 15:28:06 EDT

This archive was generated by hypermail 2.2.0 : Mon 22 Aug 2016 - 06:49:19 EDT