indentation

How to make Emacs use tabs instead of spaces?

你说的曾经没有我的故事 提交于 2019-12-23 09:35:30
问题 I've binded a indent-for-tab-command command to one the keys and I want it to make smart mode-specific indentation just like it already does but with tabs. In all the modes. It always inserts spaces instead of tabs. How to reconfigure/reprogram it? I want to use Emacs as fully customizable editor as it's announced to be. So that it would behave exactly as I want. I do not care about developers' opinions at all and want to customize everything. Is this wrong? 回答1: Not all major modes handle

Looking for a more flexible tool than GNU indent

被刻印的时光 ゝ 提交于 2019-12-23 08:26:23
问题 When I run indent with various options I want against my source, it does what I want but also messes with the placement of *s in pointer types: -int send_pkt(tpkt_t* pkt, void* opt_data); -void dump(tpkt_t* bp); +int send_pkt(tpkt_t * pkt, void *opt_data); +void dump(tpkt * bp); I know my placement of *s next to the type not the variable is unconventional but how can I get indent to just leave them alone? Or is there another tool that will do what I want? I've looked in the man page, the info

vim's tab length is different for .py files

我与影子孤独终老i 提交于 2019-12-23 08:00:07
问题 In my ~/.vimrc I set tab to me 2 spaces long set shiftwidth=2 set tabstop=2 However when I open a .py file, tabs are 4 spaces long. I don't have specific configuration for python files. ~/.vim/after is empty and searching for py doesn't raise any suspect lines. Have you ever experienced that? How to solve such a behaviour? 回答1: It’s defined in the general Python filetype plugin file ( $VIMRUNTIME/ftplugin/python.vim ): " As suggested by PEP8. setlocal expandtab shiftwidth=4 softtabstop=4

XML split attribute value on multiple line

大憨熊 提交于 2019-12-23 07:06:01
问题 I have XML data which contains a long attribute value. The value does not contain white space characters. I want to format the XML for readability by splitting the XML text so that the line does not exceed a maximum number of column. Is there any mean to accomplish this? Is there any break character that I can put at each end of line so that the XML parser does not consider it as a white space (like underscore character in visual basic)? For example: <element attribute="this_is_a_very_long

Vim: Indent current (blank) line and insert

穿精又带淫゛_ 提交于 2019-12-23 06:58:19
问题 Say I have the current text in the buffer, where _ marks the cursor int main(int argc, char **argv) { printf("Hello, world!\n"); _ } I have indentexpr on (though a solution with cindent or autoindent will probably work, too). How do I begin inserting so my cursor is placed at the appropriate column to follow the indention rules, i.e.: int main(int argc, char **argv) { printf("Hello, world!\n"); _ } Currently I find myself using ddO often (or ddo at the end of the buffer), but it seems there

How to indent if…any…do…end…end [closed]

白昼怎懂夜的黑 提交于 2019-12-23 04:33:08
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I am new to ruby and I wonder how you would indent this code: if a.any? do |blah| name = blah[:name][/.* (.*)/, 1] name = convert_name(name) text = "#{name}#{blah[:value]}" text == "b2" end puts "found" exit 1 end 回答1: I'd write it something like: if a.any? { |blah| (blah[

“Google” python style script not working

夙愿已清 提交于 2019-12-23 02:47:13
问题 I'm trying to use the Google python indentation script, but it's not working for me. I want it to indent as follows: very_long_function_name( first_param, I pasted its text onto the end of this vim script: and put it into ~/.vim/indent/python.vim . Not sure why it's not working. Edit: FIXED. I modified the indent file as follows: function GetGooglePythonIndent(lnum) " Indent inside parens. " Align with the open paren unless it is at the end of the line. " E.g. " open_paren_not_at_EOL(100, "

Indent with tab instead of spaces in Emacs ruby-mode

∥☆過路亽.° 提交于 2019-12-22 09:19:53
问题 I've been trying to configure Emacs so that it insert a 'tab' instead of a series of 'spaces' when indenting Ruby code. So far, I've tried setting the var ruby-indent-tabs-mode to t so that, as per the documentation, it would "insert tabs in ruby mode if this is non-nil.". But so far, no dice. I've also tried customising it via Easy customisation , which inserted the following into my init.el : (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you

Making a region-indent-function keep the region marked

故事扮演 提交于 2019-12-22 08:22:54
问题 I'm having trouble with haml-mode's region-indent-function , which I'm trying to reuse in another major mode. We're supposed to be able to cycle the region indentation by keeping the region marked after the haml-indent-region is being evaled, but it doesn't work as intended. After some hacking around, I've found out that throwing an error at the end of the function makes Emacs keep the region marked, as in this example: (defun haml-indent-region (start end) (save-excursion ...) (error "")) ;;

Tidying PHP and HTML Code?

北城以北 提交于 2019-12-22 08:17:35
问题 I wonder if anyone could please help me I have been using HTML tidy and eclipses built-in function to tidy up my code. I am having great trouble with the following situations... when HTML is split between files via includes, having result structured with correct indentations helps with debugging via browser tools. PHP and HTML when used together. for example PHP if statements around HTML code where you wont the correct indentation for both the PHP and HTML. (automating this How to properly