How to keep vim from indenting lines?

I want to be able to have gg=G in my bash scripts or in some autoformat options that won't prevent a simple echo.

I have a feeling that something like this is not a problem, I just did not find the right way:

  • echo line is correct for this scenario
  • enter the correct command for the job

If anyone could help me, that would be very grateful.

What am I typing:

 someFun() { echo "Some really long string that is going to be automatically indented."; } 

What I see in the tooltip

 >./someFun Some really long string that is going to be automatically indented. 
+4
source share
3 answers

You can concatenate the lines as follows:

 echo "Some really long string that is going to be automatically" \ "indented." 

disable indentation:

 :setlocal noautoindent :setlocal nosmartindent 
+1
source

Is this my current decision, any arguments or chapters?
It will be more enjoyable for the needs of the project.
which requires flexibility, including:

  1. does not affect textwidth =? multi-tenant environment
  2. independent of auto- [indent | format] * (vim, gedit, notepad ++, w / e)
  3. avoiding unpredictable withdrawal through total control

where they are unreliable:
cat <EOF ... EOF or echo shielding with "\"


I made the file / usr / bin / yell

 printTrueString() { local args=$@ ; echo $args; unset args; } printTrueString " $@ "; exit 0 


and now...

 sumFun() { #auto-indent all you want VIM or w/e!... yell "hello mad world" #just like echo -e yell -e "hello\nmad\nworld" } sumFun; exit 0 #stays on one line, where the echo would split >hello mad world >hello mad world 

you could do more ... extend echo with this as inline ...

0
source

Byter, here is a more suitable way to achieve what you need, as well as some tips for other beginners.

First of all, you should not put your own shells only in any old place, especially / usr / bin. If you have a custom application, I suggest saving it to / opt or / usr / local / bin if you need to.


Secondly, this particular shell should not be a prerequisite for any of your applications, it does not serve a purpose different from the existing one.


Instead, see the following examples:

PROBLEM>

 foo() { echo "A string that gets affected by auto-format, is a pretty long string"; } $foo >A string that gets affected by auto-format, is a pretty long string 

Solution>

 foo() { longString='A really long \nstring'; echo -e $longString } $foo >A really long string 

OR use cat eof | EOL , which will work for you if you do not specify an indent with a hyphen "-" see:

 foo() { cat <<-EOL really long string EOL } $foo >really long string 

In conclusion> . This solves your problem by providing an unobtrusive way of using strings in bash.

0
source

All Articles