Show user in vim status line2019 Community Moderator ElectionHow to replace a character by a newline in Vim?Duplicate a whole line in VimHow do I move to end of line in Vim?Indent multiple lines quickly in viVim clear last search highlightingWhat is your most productive shortcut with Vim?What's a quick way to comment/uncomment lines in Vim?How to do case insensitive search in VimHow does the vim “write with sudo” trick work?How to exit the Vim editor?
How do I hide Chekhov's Gun?
"of which" is correct here?
Happy pi day, everyone!
How do I change two letters closest to a string and one letter immediately after a string using Notepad++?
Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?
Tikz picture of two mathematical functions
Is there a hypothetical scenario that would make Earth uninhabitable for humans, but not for (the majority of) other animals?
PTIJ: Who should I vote for? (21st Knesset Edition)
I am confused as to how the inverse of a certain function is found.
Why no Iridium-level flares from other satellites?
Can I use USB data pins as power source
Most cost effective thermostat setting: consistent temperature vs. lowest temperature possible
Counting models satisfying a boolean formula
Is there a place to find the pricing for things not mentioned in the PHB? (non-magical)
What options are left, if Britain cannot decide?
What is a ^ b and (a & b) << 1?
How to make healing in an exploration game interesting
Meme-controlled people
Shortcut for setting origin to vertex
A diagram about partial derivatives of f(x,y)
How to pronounce "I ♥ Huckabees"?
New passport but visa is in old (lost) passport
Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?
What exactly is this small puffer fish doing and how did it manage to accomplish such a feat?
Show user in vim status line
2019 Community Moderator ElectionHow to replace a character by a newline in Vim?Duplicate a whole line in VimHow do I move to end of line in Vim?Indent multiple lines quickly in viVim clear last search highlightingWhat is your most productive shortcut with Vim?What's a quick way to comment/uncomment lines in Vim?How to do case insensitive search in VimHow does the vim “write with sudo” trick work?How to exit the Vim editor?
I already have set in vim a permanent status line which is quite nice, with the following config in my .vimrc
" Status line config
set statusline=
set statusline+=%< " cut at start
set statusline+=%2*[%n%H%M%R%W]%* " flags and buf no
set statusline+=%-40f " path
set statusline+=%=%1*%y%*%* " file type
set statusline+=%10((%l,%c)%) " line and column
set statusline+=%P " percentage of file
Now, as I often switch from testing to production environments, I'd like vim to show the current user, as set up by ISPconfig, in the status line.
The ability to have one user (production server) in red would be a great plus :D
vim server gnu-screen
add a comment |
I already have set in vim a permanent status line which is quite nice, with the following config in my .vimrc
" Status line config
set statusline=
set statusline+=%< " cut at start
set statusline+=%2*[%n%H%M%R%W]%* " flags and buf no
set statusline+=%-40f " path
set statusline+=%=%1*%y%*%* " file type
set statusline+=%10((%l,%c)%) " line and column
set statusline+=%P " percentage of file
Now, as I often switch from testing to production environments, I'd like vim to show the current user, as set up by ISPconfig, in the status line.
The ability to have one user (production server) in red would be a great plus :D
vim server gnu-screen
1
set statusline+=%$USER
– phd
Mar 7 at 16:11
add a comment |
I already have set in vim a permanent status line which is quite nice, with the following config in my .vimrc
" Status line config
set statusline=
set statusline+=%< " cut at start
set statusline+=%2*[%n%H%M%R%W]%* " flags and buf no
set statusline+=%-40f " path
set statusline+=%=%1*%y%*%* " file type
set statusline+=%10((%l,%c)%) " line and column
set statusline+=%P " percentage of file
Now, as I often switch from testing to production environments, I'd like vim to show the current user, as set up by ISPconfig, in the status line.
The ability to have one user (production server) in red would be a great plus :D
vim server gnu-screen
I already have set in vim a permanent status line which is quite nice, with the following config in my .vimrc
" Status line config
set statusline=
set statusline+=%< " cut at start
set statusline+=%2*[%n%H%M%R%W]%* " flags and buf no
set statusline+=%-40f " path
set statusline+=%=%1*%y%*%* " file type
set statusline+=%10((%l,%c)%) " line and column
set statusline+=%P " percentage of file
Now, as I often switch from testing to production environments, I'd like vim to show the current user, as set up by ISPconfig, in the status line.
The ability to have one user (production server) in red would be a great plus :D
vim server gnu-screen
vim server gnu-screen
edited Mar 7 at 15:52
Joel.O
asked Mar 7 at 15:13
Joel.OJoel.O
7772921
7772921
1
set statusline+=%$USER
– phd
Mar 7 at 16:11
add a comment |
1
set statusline+=%$USER
– phd
Mar 7 at 16:11
1
1
set statusline+=%$USER– phd
Mar 7 at 16:11
set statusline+=%$USER– phd
Mar 7 at 16:11
add a comment |
1 Answer
1
active
oldest
votes
OK, I spent some time learning vimscript as it is well worth it :)
So there's the relevant part to add in .vimrc in order to print the $USER variable in the status line and to color it to red (using the error system color) if the user has the value "prod".
"" Functions
function! Prodcolor()
if $USER == "prod"
set statusline+=%#error#
endif
endfunction
" Status line config
set statusline=
call Prodcolor() " Give the error color if `$USER` is "prod"
set statusline+=%$USER " Paste the current vim user
set statusline+=%* " Revert color to normal
To have it applied immediately in your current vim session, in vim type :so .vimrc
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047098%2fshow-user-in-vim-status-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
OK, I spent some time learning vimscript as it is well worth it :)
So there's the relevant part to add in .vimrc in order to print the $USER variable in the status line and to color it to red (using the error system color) if the user has the value "prod".
"" Functions
function! Prodcolor()
if $USER == "prod"
set statusline+=%#error#
endif
endfunction
" Status line config
set statusline=
call Prodcolor() " Give the error color if `$USER` is "prod"
set statusline+=%$USER " Paste the current vim user
set statusline+=%* " Revert color to normal
To have it applied immediately in your current vim session, in vim type :so .vimrc
add a comment |
OK, I spent some time learning vimscript as it is well worth it :)
So there's the relevant part to add in .vimrc in order to print the $USER variable in the status line and to color it to red (using the error system color) if the user has the value "prod".
"" Functions
function! Prodcolor()
if $USER == "prod"
set statusline+=%#error#
endif
endfunction
" Status line config
set statusline=
call Prodcolor() " Give the error color if `$USER` is "prod"
set statusline+=%$USER " Paste the current vim user
set statusline+=%* " Revert color to normal
To have it applied immediately in your current vim session, in vim type :so .vimrc
add a comment |
OK, I spent some time learning vimscript as it is well worth it :)
So there's the relevant part to add in .vimrc in order to print the $USER variable in the status line and to color it to red (using the error system color) if the user has the value "prod".
"" Functions
function! Prodcolor()
if $USER == "prod"
set statusline+=%#error#
endif
endfunction
" Status line config
set statusline=
call Prodcolor() " Give the error color if `$USER` is "prod"
set statusline+=%$USER " Paste the current vim user
set statusline+=%* " Revert color to normal
To have it applied immediately in your current vim session, in vim type :so .vimrc
OK, I spent some time learning vimscript as it is well worth it :)
So there's the relevant part to add in .vimrc in order to print the $USER variable in the status line and to color it to red (using the error system color) if the user has the value "prod".
"" Functions
function! Prodcolor()
if $USER == "prod"
set statusline+=%#error#
endif
endfunction
" Status line config
set statusline=
call Prodcolor() " Give the error color if `$USER` is "prod"
set statusline+=%$USER " Paste the current vim user
set statusline+=%* " Revert color to normal
To have it applied immediately in your current vim session, in vim type :so .vimrc
answered Mar 7 at 19:10
Joel.OJoel.O
7772921
7772921
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047098%2fshow-user-in-vim-status-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
set statusline+=%$USER– phd
Mar 7 at 16:11