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

From: Gabriel Dubatti <gdubatti.att.gmail.com>
Date: Sun, 21 Aug 2016 12:47:04 -0300

El 21/08/16 a las 12:31, Anton Pastukhov escribió:
>
> 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?
> 2. Delete trailing spaces on demand, not only on filesave?
> 3. Automatically show autocompletion suggestions after n of typed
> chars, without using keyboard shortcut (IDE-like, Sublime-like)?
> 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.
> 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?
> 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.
>
> I will appreciate any help.
>
> Anton.
>
Regarding point 2, I use this code assigned to a menu:

--delete all trailing blanks chars
function trim_trailing_spaces()
   local buffer = buffer
   buffer:begin_undo_action()
   local n=0
   for line = 0, buffer.line_count - 1 do
     local trail = buffer:get_line(line):match('^.-(%s-)[\n\r]*$')
     if trail and trail ~= '' then
       local e = buffer.line_end_position[line]
       local s = e - string.len(trail)
       buffer:set_target_range(s, e)
       buffer:replace_target('')
       n=n+1
     end
   end
   buffer:end_undo_action()
   if n > 0 then
     ui.statusbar_text= 'Trimmed lines: '..n
   else
     ui.statusbar_text= 'No trailing spaces found'
   end
end

Best regards,
Gabriel

-- 
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 - 11:47:04 EDT

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