LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-02-2019, 09:22 AM   #1
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Rep: Reputation: Disabled
How to make a change to COLUMNS variable persist and have Vim obey it also


I am trying to have my terminal be 101 columns wide and also have Vim obey this so that when I open a java file that I wrote in IntelliJ, that I have set to allow 100 characters per line, I don't have wrap around on every line over 95 characters. I have tried the following in .bashrc
Code:
COLUMNS=101
and
export COLUMNS=101
on separate tries, not together
I have also tried both of those in /etc/profile, /etc/environment, and /etc/bash.bashrc on separate occasions. also if I run command:
Code:
COLUMNS=101 
or
export COLUMNS=101
then running:
Code:
echo $COLUMNS
or 
set | less
shows the successful change, but then in Vim I am not getting 101 columns and if I run
Code:
:set columns=101
in vim some really funny stuff happens where I cannot even "l" over past column 51 on certain lines and the behavior is just off. I have, in my .vimrc,
Code:
:set colorcolumn=101
so that I can tell while coding that I need to move to a new line.

How can I have a persistant COLUMNS=101 and have Vim show 101 columns so that I have consistency between coding in IntelliJ and coding in Vim?

I am trying to do this both on my laptop which is running Arch Linux with plasma-desktop and using qterminal since Konsole sometimes crashes when I have multiple instances running and on my desktop which is running KDE-Neon and using qterminal for the same reason.

The issue is that when I have 4 terminals on one desktop I only have 95 columns wide in each, if I change the window size I can get however many columns, but I need it when I have side by side instances of qterminal on the same screen. On both my laptop and my desktop I have 1920x1080 widescreen monitors.

Last edited by Astral Axiom; 03-09-2019 at 07:10 PM. Reason: corrected value
 
Old 03-04-2019, 11:11 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,302
Blog Entries: 13

Rep: Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696
To attain a specific terminal size, I specify the geometry as part of the applet.
 
Old 03-04-2019, 12:45 PM   #3
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
To attain a specific terminal size, I specify the geometry as part of the applet.
Thanks for your reply

What is "the applet"? Is that the terminal application being used, such as qterminal or Xterm? Do you mean that you change this by settings of the terminal emulator? I do not see any setting for number of columns, only for initial window size.
 
Old 03-04-2019, 01:39 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,302
Blog Entries: 13

Rep: Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696
I may have stared it incorrectly, but you seem to understand. Yes, the shortcut, or the icon that you select when you open a terminal. Adding a --geometry argument to it usually allows me to default that window size, and thus the number of lines and columns. Also most terminals do have settings which you can set and save. For me, whatever width in pixels I set that gets me to the number of columns that I want, usually works for me. However my interest is that I like it to be most of the screen, not 1/20th of the screen. In your case, you wish to open two side by side and have them be top to bottom (?) and then half each. I get that, you may have to work with it a bit, but I think by setting the geometry it should work.
 
Old 03-04-2019, 08:48 PM   #5
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
Thanks rtmistler, I see what you mean. I have my terminal app set to open with the window size from the most recently closed session and I have 4 shortcuts that put the terminal windows in the 4 corners of the screen, one quarter of the screen for each terminal window. I also have shortcuts for two terminals each taking half the screen side by side. What I am trying to do is have 101 columns in my terminal window when the geometric size is 94 X 25 for my desktop and 95 X 25 for my laptop. My computer science professor said that it was possible the other day when I asked him about my issue of editing files I wrote in IntelliJ, that have lines with 100 characters, in vim in my console and having a lot of lines wrapping around. I was telling him I was going to set IntelliJ to wrap at 94 characters to solve the issue. However, as far as I have been able to tell thus far, the COLUMNS variable is in direct correlation with the size of the window and "echo $COLUMNS" even reflects a change in window size mid session. So it seems that my specification of "COLUMNS=101" in my .bashrc is overridden by the setting in qterminal to open with the window size from the last session. Essentially, anytime the geometric width of the terminal window is 94 I want it to have 101 columns.
 
Old 03-05-2019, 02:41 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,158
Blog Entries: 9

Rep: Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604
how are you starting vim?

i use the configuration of my (only) terminal emulator to achieve larger terminal windows, always.

i think there's a more global way of doing this, but i do not recommend it.
 
Old 03-05-2019, 06:36 AM   #7
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
how are you starting vim?

i use the configuration of my (only) terminal emulator to achieve larger terminal windows, always.

i think there's a more global way of doing this, but i do not recommend it.
I start vim with
Code:
vim file.extension
I don't have gvim, only vim. I have two terminal emulators; Konsole (default to plasma) and the one that doesn't crash when I have more than 2 instances open, qterminal (default to lxqt). I started using qterminal because it is what came default when I installed LXQT on my laptop, which runs Arch Linux, and I really liked qterminal an noticed that it does not crash even if I have 4 terminals open across 2 desktops. Out of curiosity, what terminal emulator are you using?
 
Old 03-05-2019, 09:43 AM   #8
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
Once again, however I am trying to have 101 columns in my terminal window while the geometric width of the window is 94. I want to disassociate the COLUMNS variable from the window size, maybe this is not possible, I could certainly see an issue relating to font size in this case as that may need to vary in order to keep the column number constant. Perhaps there is a way to specify the correlation between the window size and the value of COLUMNS in such a way as to allow 101 columns specifically when window width is 94 so the number of columns still varies directly with the window size. I will have to ask my professor when I see him tomorrow, I will post a solution when I find one or the fact that there is no solution if that turns out to be true(which I doubt, though the solution may more complication than it is worth). Thanks so much for the responses they are greatly appreciated, if anyone knows how to do this I would love some help.
 
Old 03-05-2019, 09:49 AM   #9
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,302
Blog Entries: 13

Rep: Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696
Sorry that's the best I have for suggestions. I do understand you wish to have it be decoupled from the window size. Some terminals or other applications allow for a setting to say Window Size != Terminal Size. Actually the opposite as a checkbox, which is to say that they allow one to set Terminal Size equal to Window Size, so you can resize your window and it will adjust the terminal settings accordingly. This doesn't seem to be an option here.
 
Old 03-05-2019, 10:10 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,495

Rep: Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312
vim can only use the terminal [full size] where it was started from. You need to use screen or tmux or something similar to split (divide) the terminal window.
 
Old 03-06-2019, 10:40 AM   #11
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
So I misunderstood my professor, he meant having a larger window size would increase the number of columns. I am not marking this solved quite yet, because I want to see if I can find the file that defines the relationship between the COLUMNS variable and qterminal's window size so that I may redefine the ratio. I imagine it is a one to one ratio currently. If anyone has any ideas, I would love to have some pointers. Thanks so much for all the replies
 
Old 03-06-2019, 01:16 PM   #12
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,495

Rep: Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312
when you open a terminal you can specify the size using -geometry (if I remember well). If you resize that terminal column will (should?) automatically reflect on it.
 
1 members found this post helpful.
Old 03-06-2019, 09:02 PM   #13
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
when you open a terminal you can specify the size using -geometry (if I remember well). If you resize that terminal column will (should?) automatically reflect on it.
Thank you, yes the COLUMNS variable changes in correspondence to the current window size while the terminal is running. What I need to do is redefine the ratio of window width to number of columns so that when the window's width is 94 there are 101 columns. I am not trying to stop the COLUMNS variable from automatically adjusting based on the current window size, only to redefine the number of columns per unit of window width so that it is no longer one to one. Perhaps it is in a window manager configuration file or in a bash configuration file or a qterminal configuration file. I have not found where this is defined yet, any clues to where this ratio may be defined would be greatly appreciated. Thanks so much for everyone's responses thus far

Last edited by Astral Axiom; 03-06-2019 at 09:05 PM. Reason: add info
 
Old 03-07-2019, 03:53 AM   #14
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,495

Rep: Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312Reputation: 4312
I think you need to change the font used by the terminal. The width of the font may influence that.
 
1 members found this post helpful.
Old 03-07-2019, 07:05 AM   #15
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 5,332

Rep: Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959Reputation: 1959
To create this screenshot from my 1080p monitor I put into ~/.vimrc
Code:
set lines=30 columns=101
and used this command to start the xterm sessions
Code:
xterm -g 102x32+0+0  -bg black -fg white -fn -*-terminus-medium-*-*-*-15-*-*-*-*-*-*-*
Attached Thumbnails
Click image for larger version

Name:	snapshot.png
Views:	11
Size:	75.9 KB
ID:	30037  

Last edited by allend; 03-07-2019 at 07:07 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Merging columns from different files and renaming columns lharrisl Linux - Newbie 7 05-23-2016 08:36 AM
[SOLVED] Fedora shows 'man vim' but when execute 'vim' got "bash: vim: command not found..." ? flash_os Linux - Newbie 19 01-04-2015 12:56 AM
[SOLVED] Converting a file with Rows and Columns to just Columns mphillips67 Linux - Newbie 14 03-05-2014 11:31 AM
Switching from vim to vim -g from inside vim iDragoon Linux - Software 4 05-15-2009 12:46 PM
Editor comparison: vim VS vim-lite, Cleaning vim Ruler2112 *BSD 4 04-13-2009 05:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration